#Rust
9 posts tagged Rust. All posts
Cow<str> in Rust: borrow when you can, allocate when you mustHow Rust's Cow<str> lets a function return its input untouched or a new String: a whitespace normaliser, into_owned, to_mut, Cow fields, and from_utf8_lossy.
Writing a parser in Rust with nom 8Parse key=value log lines in Rust with nom 8: the Parser trait and .parse(input), core combinators, typed values with map_res, cut for clearer errors, and tests.
Property-based testing in Rust with proptestUse proptest to test a Rust run-length encoder: the proptest! macro, strategies, prop_assert, how shrinking finds a minimal failing input, and regression files.
Watching files for changes in Rust with the notify crateUse notify 8 to watch directories in Rust: raw events and their kinds, debouncing with notify-debouncer-mini and -full, a rerun-on-change tool, and platform limits.
Builders and the typestate pattern in RustFrom a plain Rust builder to one where missing required fields are compile errors, then a PhantomData state machine, with the trade-offs of encoding state in types.
Writing a Python extension in Rust with PyO3 0.28 and maturinBuild a Python module in Rust with PyO3 0.28 and maturin: #[pyfunction], a declarative #[pymodule], the Bound API, py.detach for threads, and wheels.
Serde attributes in Rust: rename, default, flatten and enum taggingThe serde attributes that shape your JSON: rename_all, default, skip_serializing_if, flatten, deny_unknown_fields, the four enum representations, and with.
Tokio channels in Rust: mpsc, oneshot, broadcast and watchWhen to use each Tokio channel: bounded mpsc and backpressure, an actor with oneshot replies, broadcast lag, watch for config, and shutting tasks down cleanly.
A REST API in Rust with Axum 0.8 and SQLxBuild a small todo API with Axum 0.8 and SQLx on SQLite: routing with /{id} paths, State and Json extractors, migrations, an error type, and oneshot tests.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)