Use rustup to install the toolchain.
Installing the Rust compiler and toolchain
Google's Rust training
- The Rust Standard Library Cookbook might be the most helpful intro book that I've read in terms of items like Rc and examples using them. Review its bookmarks.
- Rust book
- The Rustonomicon
- Rust Fuzz book
- Rust by Example
- Rust Reference
- The Cargo book
- Command-Line Rust (which I have) walks through reimplementing core linux tools (head, wc, etc.).
Rust on Nails uses development containers in VS Code for a rust app. Very helpful.
async/await Pin related Futures
A great walkthrough of error handling by the Zero to Production in Rust author.
Recoverable Errors with Result
Paraphrasing: But if you need to squeeze every bit of speed out of it, add lto = true to your release profile in your cargo.toml to enable link time optimizations. It increases build times for your release builds, but I find it gives 10-20% better performance.
More: cargo run will also build, so if you do cargo build --release followed by cargo run then it will run an unoptimized build
Outlines the various meanings of 'lifetime' wording.
A great writeup detailing differences of Fn, FnOnce, and FnMut.
This covers the hows and whys of moving from logging to tracing.
OP asked about mutability, but the core issue involves ownership.
We can use as &_ and others.
//option 1
let x = &mut whatever;
let y = &*x;
//option 2
let y: &_ = x;
//option 3
let x = &*x;Concat various types
Function arguments can be destructured as shown in this thread.
In Rust, anytime you have a binding -- ie, you define a name for a variable -- you have pattern-matching:
let Args { opt_a, opt_b } = args;
fn foo(Args { opt_a, opt_b }: Args);For let, you can even use refutable patterns, by using let..else:
let Some(a) = a /_Option<A>_/ else {
return x;
};More examples
struct Args { opt_a: i32, opt_b: u32, }
//fn my_function(args: Args) {}
fn my_function(Args {opt_a, opt_b}: Args) {
println!("{} {}", opt_a, opt_b);
}
fn main() {
my_function(Args { opt_a: 1, opt_b: 4, });
}and Defaults can be added by implementing Default on the Args struct and using ..Default::default() at the callsite.
From and Into round-up
TODO: pull the important bits from the following
https://old.reddit.com/r/rust/comments/14uxt10/from_vs_into_which_should_generic_free_functions/
https://ricardomartins.cc/2016/08/03/convenient_and_idiomatic_conversions_in_rust
https://github.com/sger/RustBooks
You can implement a trait for Reference which they say can also be done for Mutable Reference.
godbolt can be used to decompile a rust program.
criterion for benchmarks cargo-flamegraph for performance profiling dhat for heap profiling
For any crates you like at crates.io, add them to your following list.
Check for gems here
Link to std lib. Link to crate docs.
Blessed - An unofficial guide to the Rust ecosystem
Check out the github star list.
A tour of standard library traits.
Rustlings are small exercises.
From Learn Rust the Dangerous Way
- Document the compiler version you tested with, or ideally, pin it in your build system. (Rust has the rust-toolchain file to do this.)
- Include a benchmark test that will indicate if things have suddenly gotten slower, so you can at least know to investigate. Ensure that this test runs as part of the build or continuous integration flow. (For Rust projects using Cargo, I recommend Criterion.)
A great deep dive into unique access.