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)
- Go to Rust by Example
- Copy an example
- Paste it into src/main.rs (replace previous code)
- Save (Ctrl + S)
- Run:
Bash
cargo +nightly run
5. Recommended Learning Order
- Hello World
- Comments
- Formatted print
- Variables
- Types
- Functions
- Control Flow
- Ownership & Borrowing (most important)
- References
- Lifetimes (basic)
- Structs
- Enums
- Pattern Matching (match)
- Methods
- Modules
- Error Handling
- Collections
- Traits
- 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.
