Setting Up Rust + Learning Workflow

Personal reference notes)

1. Toolchain Setup

  • Installed / updated Rust with rustup
  • Stable version: 1.97.1
  • Nightly version: 1.99.0-nightly
  • Enabled Polonius (improved borrow checker) with:

toml

# .cargo/config.toml
[build]
rustflags = ["-Zpolonius=next"]

Because of this, I need to use the nightly toolchain when building:

Bash

cargo +nightly run
cargo +nightly build

2. Editor Setup (VS Code)

  • Installed VS Code
  • Installed rust-analyzer extension + component
  • Added useful settings for better Rust experience (inlay hints, format on save, clippy, etc.)
  • Created aliases:

Bash

alias c="code ."
alias polonius="code ~/polonius_test"

3. Project

Created a test project:

Bash

cargo +nightly new polonius_test
cd polonius_test

4. How I Run Examples (Rust by Example workflow)

  1. Go to Rust by Example
  2. Copy an example
  3. Paste it into src/main.rs (replace previous code)
  4. Save (Ctrl + S)
  5. Run:

Bash

cargo +nightly run

5. Recommended Learning Order

  1. Hello World
  2. Comments
  3. Formatted print
  4. Variables
  5. Types
  6. Functions
  7. Control Flow
  8. Ownership & Borrowing (most important)
  9. References
  10. Lifetimes (basic)
  11. Structs
  12. Enums
  13. Pattern Matching (match)
  14. Methods
  15. Modules
  16. Error Handling
  17. Collections
  18. Traits
  19. Generics

6. Useful Commands

Bash

# Run the program
cargo +nightly run

# Check for errors without running
cargo +nightly check

# Build only
cargo +nightly build

# Open project in VS Code
c
# or
polonius

Notes to self:

  • Always use cargo +nightly in this project because of Polonius.
  • Focus extra time on Ownership, Borrowing, and Lifetimes.
  • When confused by an example, experiment by changing the code.