Cargo Info in Neovim, or How Simple Features Go a Long Way

TL;DR Open cargo info in Vim or neovim for the package under the cursor using these 4 lines of Lua. Cargo info Rust 1.82 was released a couple of days ago. It’s packed with improvements, but one in particular caught my eye. Cargo now has a info sub-command. It displays details about a package in the registry from the comfort of your terminal. Here is an example: $ cargo info lazy_static lazy_static #macro #lazy #static A macro for declaring lazily evaluated statics in Rust. version: 1.5.0 license: MIT OR Apache-2.0 rust-version: unknown documentation: https://docs.rs/lazy_static repository: https://github.com/rust-lang-nursery/lazy-static.rs crates.io: https://crates.io/crates/lazy_static/1.5.0 features: spin = [dep:spin] spin_no_std = [spin] note: to see how you depend on lazy_static, run `cargo tree --invert --package lazy_static@1.5.0` Vim and neovim generally composes well with other terminal tools. So how can we easily integrate cargo info and neovim? ...

October 21, 2024 · 4 min · Clément Joly

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. Prior to the patch, it looked roughly2 like this: ...

June 25, 2022 · 5 min · Clément Joly

Rusqlite Migration

 cljoly/rusqlite_migration ...

Sesters

 cljoly/sesters ...