[Thiago Cafe] Programming is fun!

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember

How to deserialise DateTime from toml configuration

(Posted 2024-04-25 17:07:56)

When implementing a new configuration parameter for Texted, I needed something to represent the date the blog started.

When looking into the TOML website, I was fortunate to discover that it has a data type for dates, so I could create the new parameter

blog_start_date = 2016-06-25

However, my fortune was gone as I found that the Toml crate does not support deserialising.

... more ...

How to sort a vector of a custom struct in Rust

(Posted 2024-03-08 04:39:59)

When implementing tags for Texted2, I had a list of tags being:

let tags: Vec<(&str, u32)>; // Tag name, number of posts containing this tag

And I need to sort it by the second item of the tuple, the tag count.

... more ...

Texted2 released!

(Posted 2024-02-29 23:59:18)

Some years ago, I create a blog application in D and called Texted. The idea that time was to learn D using a project. This time, to learn Rust, I created a new version of that same blog application, but faster and improved.

I present you, texted2!

https://gitlab.com/thiagomg/texted2/

... more ...

A simple guide to unit tests in Rust

(Posted 2024-02-27 06:15:19)

A very important part of any software are the unit tests, after all, they help us verifying that the cases that are in our heads are indeed correctly implemented and also that whoever is the next lucky fellow changing our code in the future (it might be ourselves!) will feel confident that their change won't break the application.

Rust implements tests in the same file that you are implementing your functions. I will first show one example and later explain how it works.

Creating the Unit Test

First, let's see a piece of code I used in a tool to generate posts for my newly rewritten blog system Texted2

... more ...

Pages: 1

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember