Rust Crates

List of my Rust crates. ...

Rusqlite Snapshot Testing

 cljoly/rusqlite-snapshot-testing ...

Rusqlite Changelog

Release notes for the rusqlite_migration library. Version 2.4.0 Dependencies Rusqlite was updated from 0.37.0 to 0.38.0. Please see the release notes for 0.38.0, there are a few breaking changes in this one. Update other deps dependencies, see git history for details. Features Rusqlite 0.38 makes the cache statement optional. This feature was used for foreign key checks. The rusqlite_migration library does not enable any features from rusqlite, not even the default one. This way, downstream users can freely chose which feature to enable based on their needs. As a result, rusqlite_migration now handles statement caching for foreign key checks internally now. As side benefit, this also makes caching more efficient: the prepared statement is kept for the minimum time where it is needed and freed immediately, without taking space in the global cache used by rusqlite. ...

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

Rust Default Values for Maintainability

⚡ TL;DR The Default trait can enhance the maintainability 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

Sesters

 cljoly/sesters ...