Rust
Bits and pieces of Rust
Useful commands
To override default toolchain for a particular project:
rustup override set nightly
. The directory is stored in~/.rustup/settings.toml
(inoverrides
section) separately from the project itself.To print all package dependencies as a nice tree in the command line, we can use
cargo tree
- more details here (works starting from Rust 1.44)
Closures
A good post by Steven Donovan about closures in Rust. It makes the connection between closures and structs, explains why
move |...|
is sometimes needed and why we have to add lifetimes annotations likewhere F: Fn(i32) -> i32 + 'a>
All the nitty-gritty details are available in the Rust language reference (sections "Closure expressions" and "Closure types").
Common/standard traits, conversion
"Rust's Built-in Traits, the When, How & Why" by Lloqiq (2015)
"The Common Rust Traits" by Steve Donovan (2018)
"Use conversion traits" part from "Designing elegant APIs in Rust" by Pascal Hertleif (a very insightful post!) (2016)
"Conversion" section in "Rust by Example"
"Convenient and idiomatic conversions in Rust" by Ricardo Martins (2016)
Rust reference: "Special types and traits"
Lifetimes, NLL
RFC-2094 about Non-Lexical Lifetimes: why and when they are needed, design
"Lifetimes" and the following sections in Rustonomicon
"Understanding Rust Lifetimes" by Maksym Zavershynskyi
Error handling
Error handling survey - 13 Nov 2019 - many error handling packages reviewed and compared
Error handling in Rust by Andrew Gallant (burntsushi)
Notice: failure is deprecated on Reddit
Profiling on Mac
Profiling with
sample
"Rust profiling with DTrace and FlameGraph on MacOs" by Carol Nichols, a simple easy to follow reference
Inferno by Jon Gjengset for producing flame-graphs from process samples. Rust port of flame-graph tools. Its README.md on GitHub has lots of useful information. Btw, there is a 5 hours video stream of how this tool was actually coded live!
Misc
"Rust Tidbits: What is a Lang Item?" - an interesting explanation about traits and other items known to the Rust compiler and marked with
#[lang]
annotation. I really enjoyed this article, but for some reason it was quite hard to google to find it again (perhaps because I googled "traits" and "lang" is not a very googleable term).
Last updated