Rust Practice (Basics)
Intuition
Learning through practice: Practice problems are like training drills — they help you apply knowledge and identify areas that need more study.
Why it matters: Regular practice builds confidence and reveals patterns in how concepts are tested. Each problem reinforces key programming concepts.
The key insight: Making mistakes during practice is valuable — each error points to a concept that needs clarification.
Rust — Interactive Practice
10 auto-graded practice problems covering core Rust concepts from ownership to concurrency. Select an answer, submit, and review the explanation.
Ownership and Mutability
Lifetimes and Trait Bounds
Traits and Generics
Concurrency and Unsafe
Cross-References
- Rust Flashcards: Interactive flashcards covering ownership, borrowing, and concurrency.
- Go Concurrency: Channel-based concurrency compared to Rust’s async model.
- Haskell Concurrency: STM and parallel strategies as alternatives to async cancellation.
Common Mistakes
Using unwrap() in production code: unwrap() panics on None/Err, crashing the program. Use pattern matching, ? operator, or unwrap_or/unwrap_or_else for graceful error handling.
Confusing Rc with Arc for threading: Rc is not Send or Sync — it cannot be shared across threads. Use Arc for multi-threaded shared ownership and Rc for single-threaded scenarios.
Ignoring cancellation safety in select!: Futures that are not cancellation-safe can leave shared state inconsistent when dropped by select!. Always use cancellation-safe operations in select branches.