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

Local NeoVim Plugin Development

2023-05-20: Updated to account for the features of NeoVim 0.9 and obsolete plugins You have found a (Neo)Vim plugin that you want to fiddle with, either to contribute changes upstream or for your own use. Sounds familiar? Here are some tips and tricks I use for my NeoVim plugin development. The aim of these small tricks is to iterate faster on changes, by loading your changes in a live NeoVim instance as quickly as possible....

November 2, 2021 · 3 min