Rust in Action
Last edited
Basics
| name | purpose |
|---|---|
| rustup | manages rust installs |
cargo | build system project management and package manager |
| rustc | rust compiler |
| crate | a package in rust |
Commands
rustup doc # your local rust install documentation
cargo new # create a new project
cargo run # runs cargo build then runs the exe
cargo run --release # macro: 'debug_assertions' OFF, so this will not compile
# code that is guard by this macro.
cargo run -q # quiet
cargo doc # build html docuemntatin for every dependency in the project
cargo install {crate} # install crates
cargo add {crate} # add crate to Cargo.toml
cargo doc # render documentation for all crates you depend on
cargo doc --open// format as a binary via the std::fmt::Binary trait with 32 zeroes padded on the left
println!("{:032b}", x);
//01000010001010011010111000010100
Attributes
Lexicon
# // Inner - applies to the thing it's infront of
#! // Outer - applies to the thing it's inside of
// Same logic as comments for documentation /// (infront of) and //! (module level)
Inner
#![allow(unused_variables)] // tells the compiler..
Outer
#[derive(Debug)] // generates a debug string for your struct or enum