mirror of
https://github.com/learning-forge/marshal-rust.git
synced 2026-11-30 21:30:31 +00:00
- Add .gitignore to exclude local book PDFs and compiled Rust artifacts - Document reference book metadata and 3-part study loop in README.md and NOTES_TEMPLATE.md - Rewrite 01-introduction-to-rust/README.md as a concise active-learning example with mylib/ listings - Adapt 02-getting-started/README.md to template with NixOS Home Manager toolchain setup
2. Getting Started
Reference: Donis Marshall, Programming with Rust (2024) — Chapter 2 Phase: 1 (Basics & Tooling) | Code: (add crate/file link as you go)
1. Mental Model (My Own Words)
- Core idea: Getting a working Rust toolchain, compiling with
rustcvs. managing projects withcargo, and understanding the entry point (main), libraries, comments, and CLI arguments. - Installing Rust on NixOS (instead of
rustup):- On macOS/Windows/traditional Linux,
rustupdownloads toolchains into~/.cargo/binand switches betweenstable,beta, andnightly. - On NixOS, Home Manager manages the global toolchain declaratively in
~/Config/home/dev.nix(cargo,rustc,rustfmt,clippy,rust-analyzer, andgccas linker, exposed in/etc/profiles/per-user/$USER/bin/). Installingrustupalongside Nix-managed binaries is redundant and risksPATHshadowing. - Per-project overrides: When a project needs a pinned Rust version or cross-compilation targets (what the book calls "Advanced Rustup"), use a per-project
flake.nixdevShellinstead ofrustup toolchain. - User-installed binaries:
~/.cargo/binstays onPATHfor tools installed viacargo install.
- On macOS/Windows/traditional Linux,
- Remaining Chapter 2 topics to distill as I read:
rustcdirect compile vs.cargo new/cargo build/cargo run- Binary (
src/main.rs) vs. Library (src/lib.rs) crates and published crates (crates.io) main()signatures, doc comments (///), andstd::env::args()
2. Break-It Experiments
Ideas to test in cargo as I work through the chapter:
- Experiment 1 (
rustcvscargo): Compile a standalonehello.rswithrustc, then create a Cargo package and compare whatCargo.toml/target/generate.- Result /
rustcmessage: (fill in) - Takeaway: (fill in)
- Result /
- Experiment 2 (Tooling checks): Run
rustc --version,cargo --version,cargo clippy, andcargo fmt --checkon a tiny crate.- Result: (fill in)
- Takeaway: (fill in)
3. Friction Log ("Gotchas")
- NixOS
clippybinary name:which clippyfails because the subcommand binary iscargo-clippy—always invoke it ascargo clippy. - (Add compiler/Cargo gotchas here as you hit them.)
4. Recall Prompts (Answer Without Looking)
- Why do we avoid
rustupon NixOS when Home Manager already providesrustcandcargo, and what replacesrustupfor pinned per-project toolchains? - What is the difference between running
rustc main.rsdirectly vs.cargo run? - Where do
cargo installbinaries live, and how doesPATHfind them?