Rust Default Values for Maintainability

TL;DR The Default trait can enhance the maintenability of your code. Default values for common types are listed at the end. A PR Review Recently, while reviewing a PR1, I noticed that part of the patch was introducing a new field to a struct: 1diff --git a/src/lib.rs b/src/lib.rs 2index eba9a3a..8619e06 100644 3--- a/src/lib.rs 4+++ b/src/lib.rs 5@@ -106,8 +108,9 @@ use std::{ 6 #[derive(Debug, PartialEq, Clone)] 7 pub struct M<'u> { 8 up: &'u str, 9 down: Option<&'u str>, 10+ foreign_key_check: bool, 11 } 12 13 impl<'u> M<'u> { 14@@ -137,8 +140,9 @@ impl<'u> M<'u> { 15 pub const fn up(sql: &'u str) -> Self { 16 Self { 17 up: sql, 18 down: None, 19+ foreign_key_check: false, 20 } 21 } That prompted me to reflect on the code I had initially written....

June 25, 2022 · 5 min

Rusqlite Migration

 cljoly/rusqlite_migration Rusqlite Migration is a simple and performant schema migration library for rusqlite. Performance: Fast database opening: to keep track of the current migration state, most tools create one or more tables in the database. These tables require parsing by SQLite and are queried with SQL statements. This library uses the user_version value instead. It’s much lighter as it is just an integer at a fixed offset in the SQLite file....

Sesters

 cljoly/sesters Getting started Install the latest version: $ cargo install sesters Exemple of plain text conversion: $ sesters convert a price burried 1 USD in text USD 1.00 ➜ EUR 0.89 $ sesters convert -- -1 € EUR -1.00 ➜ USD -1.10 $ sesters convert I can type and press enter EUR 2356 EUR 2345.00 ➜ USD 2586.53 It is then visible in the history:...