My run through the Rust book
Some useful commands:
- To create a new project:
cargo new some_rust_project - To check the current project:
cargo check - To build the current project:
cargo build(--releasewill build with optimizations) - To run current project:
cargo run; if multiple targets are available you'll need to add the default-run manifest key - To run a specific file:
cargo run --bin structs - To compile a specific file:
rustc src/structs.rs -o main - To update Rust:
rustup update - To generate local documentation:
rustup doc - To format the code:
cargo fmt - To check the code for issues:
cargo clippyorcargo clippy -- -A clippy::all(also see docs) - To update dependencies:
cargo update - To show dependencies:
cargo tree - To remove unused installed dependencies:
cargo clean - To run tests:
RUST_BACKTRACE=1 cargo test [--bin <binary name>]
The Rust module system, includes:
- Modules and use: Let you control the organization, scope, and privacy of paths
- Crates: A tree of modules that produces a library or executable (we have binary and library crates)
- Packages: A Cargo feature that lets you build, test, and share crates
- Paths: A way of naming an item, such as a struct, function, or module
Other resources:
- Rust Api Guidelines
- Rust crate registry
- To display stack traces run with
RUST_BACKTRACE=1orRUST_BACKTRACE=full