Skip to content

Latest commit

 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust — Tools, Books, Projects

Tools

Built into the toolchain

rustfmt — automatic code formatting

cargo fmt                    # format the entire project
cargo fmt -- --check         # check without modifying (CI)
rustfmt src/main.rs          # single file

clippy — linter, catches anti-patterns and suggests idiomatic Rust

cargo clippy                          # run the linter
cargo clippy -- -W clippy::pedantic   # pedantic mode
cargo clippy --fix                    # auto-fix what it can

miri — interpreter that detects undefined behavior at runtime

rustup +nightly component add miri
cargo +nightly miri run               # run program under miri
cargo +nightly miri test              # run tests under miri

Detects: use-after-free, out-of-bounds, data races, unsafe bugs, uninitialized memory.

rust-analyzer — LSP server for editors (VS Code, Neovim, Helix)

VS Code: install the "rust-analyzer" extension
Provides: autocompletion, inline errors, go-to-definition, refactoring, inline type hints

cargo doc — generate documentation from comments

cargo doc --open               # generate and open in browser
cargo doc --no-deps            # without dependency docs

cargo test — running tests

cargo test                     # all tests
cargo test test_name           # specific test
cargo test -- --nocapture      # show println! output in tests
cargo test -- --test-threads=1 # run tests sequentially

cargo bench — benchmarks

cargo bench                    # run benchmarks (nightly)

Additional tools (cargo install)

cargo-watch — automatic recompilation on file changes

cargo install cargo-watch
cargo watch -x check           # check on every save
cargo watch -x test            # run tests on every save
cargo watch -x run             # run program on every save
cargo watch -x 'test -- --nocapture'  # tests with output

bacon — alternative to cargo-watch with a nicer UI

cargo install bacon
bacon                          # default: cargo check in watch mode
bacon test                     # watch mode for tests
bacon clippy                   # watch mode for clippy

cargo-expand — shows expanded macros (what derive/macro generate)

cargo install cargo-expand
cargo expand                   # entire project
cargo expand module_name       # specific module

cargo-edit — manage dependencies from the terminal

cargo install cargo-edit
cargo add serde --features derive      # add a dependency
cargo add tokio --features full        # add with features
cargo rm serde                         # remove a dependency
cargo upgrade                          # update dependencies

cargo-audit — check dependencies for known CVEs

cargo install cargo-audit
cargo audit                    # scan dependencies
cargo audit fix                # fix what it can

cargo-flamegraph — performance profiling, generates flamegraphs

cargo install flamegraph
cargo flamegraph               # profile + chart (requires perf/dtrace)
cargo flamegraph --bin myapp   # specific binary

cargo-tarpaulin — code coverage

cargo install cargo-tarpaulin
cargo tarpaulin                # coverage report
cargo tarpaulin --out html     # HTML report

Debugging

GDB

cargo build
gdb target/debug/myapp
(gdb) break main
(gdb) run
(gdb) print variable_name
(gdb) bt                      # backtrace

LLDB

cargo build
lldb target/debug/myapp
(lldb) breakpoint set --name main
(lldb) run
(lldb) frame variable          # show variables

VS Code — CodeLLDB extension, clickable breakpoints in the editor.

Sanitizers (nightly)

RUSTFLAGS="-Z sanitizer=address" cargo +nightly run    # memory errors
RUSTFLAGS="-Z sanitizer=thread" cargo +nightly run     # data races
RUSTFLAGS="-Z sanitizer=leak" cargo +nightly run       # memory leaks

Books

General — after The Rust Programming Language

Rust by Example — same topics as the Book, but through code examples. Free online. Skim quickly, jump to topics that didn't stick. https://doc.rust-lang.org/rust-by-example/

Rust Atomics and Locks (Mara Bos) — multithreading, atomics, memory ordering, building mutexes from scratch. Free online. Best book for understanding concurrency in Rust. https://marabos.nl/atomics/

Programming Rust (Blandy, Orendorff, Tindall) — O'Reilly. Deeper explanations of ownership, lifetimes, traits. Good as a second pass after the Book if something didn't click.

Rust in Action (McNamara) — projects: CPU emulator, operating system, networking. Practical approach.

Rust Design Patterns — idioms and design patterns specific to Rust. Free online. https://rust-unofficial.github.io/patterns/

The Rustonomicon — unsafe Rust, FFI, raw memory, type layout, UB. Read when you need to write unsafe. https://doc.rust-lang.org/nomicon/

The Rust Reference — dry language specification. Reference, not a textbook. https://doc.rust-lang.org/reference/

Rust Macro Book — procedural and declarative macros in detail. https://danielkeep.github.io/tlborm/book/

Embedded

The Embedded Rust Book — Rust on microcontrollers, bare metal, no_std. Start here. https://docs.rust-embedded.org/book/

Discovery Book — step-by-step tutorial with the STM32F3DISCOVERY board. https://docs.rust-embedded.org/discovery/

Embassy Book — async framework for embedded. Modern approach to firmware in Rust. https://embassy.dev/book/

Multithreading & systems — theory (language-agnostic)

The Art of Multiprocessor Programming (Herlihy, Shavit) — the bible of lock-free data structures and concurrent algorithms.

Is Parallel Programming Hard, And, If So, What Can You Do About It? (McKenney) — free. Memory model, barriers, RCU. Written from a Linux kernel perspective.

The Little Book of Semaphores (Downey) — free. Collection of synchronization puzzles as a warm-up.

Crafting Interpreters (Nystrom) — free online. Not about multithreading, but an ideal project to implement in Rust. https://craftinginterpreters.com/


Projects

Weekend (1–3 days)

CLI tool — something you'll actually use. Ideas: JSON↔YAML↔TOML converter, batch file renamer, log parser, dotfiles tool, terminal todo list. You'll learn: clap (arguments), serde (serialization), anyhow (error handling), filesystem operations.

Terminal game — snake, tetris, game of life. You'll learn: loops, data structures, input handling. Use crossterm for terminal UI.

One week

Shell — simple command interpreter. Input parsing, fork/exec, pipes, redirections. You'll learn: POSIX FFI, unsafe, process management, ownership in practice.

HTTP server from scratch — raw TCP sockets, request parsing, serving files. Then rewrite with tokio + axum. You'll learn: networking, async vs sync on a real example, Arc<Mutex<T>>.

Key-value database — disk read/write, simple protocol, buffering. You'll learn: serialization, concurrency, Rc/Arc, Mutex, lifetimes.

Two weeks

Lox interpreter — from "Crafting Interpreters". Lexer, parser, AST, evaluator. You'll learn: enums with data, pattern matching, Box, recursion, trait objects. Everything from the Book suddenly makes sense.

Ray tracer — "Ray Tracing in One Weekend" in Rust instead of C++. You'll learn: heavy computation, zero-copy, performance, multithreading with rayon.

Embedded

LED blink — embassy + STM32/nRF. Absolute minimum to verify the toolchain. UART communication — sending/receiving data over serial. Sensor + display — I2C/SPI, sensor reading, OLED display output. Simple RTOS-like project — multiple tasks, interrupts, DMA.


Popular crates to remember

Error handling: anyhow (applications), thiserror (libraries) Serialization: serde + serde_json / serde_yaml / toml CLI: clap (argument parsing) HTTP: reqwest (client), axum (server), tokio (async runtime) Logging: tracing, env_logger + log Testing: assert_cmd (CLI tests), mockall (mocks), proptest (property testing) Multithreading: rayon (data parallelism), crossbeam (lock-free data structures) Embedded: embassy, cortex-m, stm32-hal, nrf-hal


.gitignore for Rust projects

target/

No leading slash — catches target/ at any nesting level. Cargo.lock — commit for binaries, don't commit for libraries.

About

Rust learning journey — Rust by Example, The Rust Programming Language, The Macro Book, Rustonomicon & Rustlings

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages