Skip to main content

End of the Rust Course

Summary and Final Challenge

Congratulations! You have completed all 10 modules and 24 lessons of the Rust course — from immutable bindings and pattern matching to ownership, NLL borrowing, traits, lifetimes, zero-cost iterators, Cargo testing, and Arc<Mutex<T>> concurrency.

10 modules · 24 lessons · 120 checkpoints

Rust exercises are verified locally in the browser using Tree-sitter AST parsing (`tree-sitter-rust.wasm`) plus structural and keyword checks; for live compilation with rustc, click Open on Rust Playground (play.rust-lang.org).

01 · Fundamentals and Typification

Default immutability, explicit mutability, shadowing, scalar and compound types with static checking.

  • let / mut / shadowing
  • const
  • i32 / f64 / bool / char
  • tuple / array / &str

02 · Flow Control & Pattern Matching

Conditional expressions, safe loops, handling of `Option<T>` and exhaustive matching guaranteed by the compiler.

  • if expression
  • loop / while / for..in
  • Option<T>
  • match / if let

03 · Ownership, Move and Borrowing

The heart of Rust security: Stack vs Heap, Move semantics, Shared/Exclusive Borrowing, NLL and slice.

  • Move (Heap String)
  • Copy / Clone
  • &T / &mut T
  • NLL / Slice &str

04 · Structures and Methods

Data modeling with classical struct, tuple struct, automatic drifts, and encapsulation using `impl` blocks.

  • struct / tuple struct
  • &self / &mut self
  • Self::new()
  • #[derive(Debug)]

05 · Generics and Traits

Zero-cost abstractions with parameters of type `<T>`, monomorphization, interfaces `trait` and constraints `where`.

  • fn<T>
  • trait / impl Trait for T
  • where bounds
  • static dispatch

06 · Lifetimes & Smart Pointers

Prevent dangling references with explicit lifetimes `'a` and handle advanced ownership with `Box<T>`, `Rc<T>` and `RefCell<T>`.

  • lifetime 'a
  • elision rules
  • Box<T> recursive
  • Rc<T> / RefCell<T>

07 · Collections and Error Handling

Standard data structures in Heap (`Vec`, `String`, `HashMap`) and robust handling of recoverable errors with `Result` and `?`.

  • Vec<T> / HashMap
  • Result<T, E>
  • ? operator
  • From / custom Error

08 · Closures and Iterators Zero-Cost

Functional programming in Rust compiled into optimal machine loops using `Fn*` closures and lazy pipelines.

  • Fn / FnMut / FnOnce
  • move closures
  • .map() / .filter()
  • .collect() / .fold()

09 · Modules, Cargo and Testing

Organize crates and modules with granular visibility, manage Cargo dependencies, and write robust test suites.

  • mod / pub(crate)
  • use / crate::
  • Cargo.toml / crate
  • #[cfg(test)] / assert!

10 · Advanced Traits and Fearless Concurrency

Fundamental traits of the standard library, dynamic dispatch with `dyn Trait`, safe threads, `mpsc` and `Arc<Mutex<T>>` channels.

  • From / Into / Deref
  • Box<dyn Trait>
  • thread::spawn / mpsc
  • Arc<Mutex<T>> / Send+Sync

The Final Challenge, in Five Steps

Combine idiomatic Rust patterns across five progressive stages: expression-based predicate is_even, in-place mutation via &mut i32, Counter struct + impl, iterator pipeline with ?, and thread-safe shared state using Arc<Mutex<usize>>.

1 · Expression-Based i32 Predicate

Implement `is_even(n: i32) -> bool` returning an expression cleanly without a trailing semicolon (Module 1 + Module 2).

Exercise#rust.boss.e1
Attempts: 0Loading…

Define fn is_even(n: i32) -> bool returning n % 2 == 0 as the final expression of the function.

Loading editor…
Show hint

Write n % 2 == 0 directly without return or a trailing ;.

Solution available after 3 attempts

2 · In-Place Mutation via &mut Reference

Apply borrowing rules by dereferencing an exclusive mutable borrow `&mut i32` (Module 3).

Exercise#rust.boss.e2
Attempts: 0Loading…

Define fn square_by_ref(n: &mut i32) that squares the referenced integer via explicit dereferencing (*n).

Loading editor…
Show hint

Inside square_by_ref, write *n = *n * *n; (or *n *= *n;).

Solution available after 3 attempts

3 · Struct Constructor & impl Methods

Combine `struct Counter`, `&mut self`, and `&self` inside an idiomatic `impl` block (Module 4).

Exercise#rust.boss.e3
Attempts: 0Loading…

Implement struct Counter { count: u32 } with public associated constructor pub fn new() -> Counter plus pub fn increment(&mut self) and pub fn get_count(&self) -> u32.

Loading editor…
Show hint

new() returns Counter { count: 0 }, increment(&mut self) executes self.count += 1;, and get_count(&self) returns self.count.

Solution available after 3 attempts

4 · Iterator Pipeline + ? Propagation

Parse string slices propagating ParseIntError with `?` and filter even values with `.iter().filter().sum()` (Module 7 + Module 8).

Exercise#rust.boss.e4
Attempts: 0Loading…

Implement fn sum_even_parsed(items: &[&str]) -> Result<i32, std::num::ParseIntError> parsing entries with s.parse::<i32>()? and summing only even values.

Loading editor…
Show hint

Either loop with s.parse::<i32>()? or collect items.iter().map(|s| s.parse::<i32>()).collect::<Result<Vec<i32>, _>>()?, then filter n % 2 == 0 and sum.

Solution available after 3 attempts

5 · Thread-Safe Counter with Arc<Mutex<usize>>

Share mutable state across threads cleanly via atomic reference counting `Arc::clone` and RAII locking `Mutex` (Module 10).

Exercise#rust.boss.e5
Attempts: 0Loading…

Complete fn count_concurrent(steps: usize) -> usize allocating Arc::new(Mutex::new(0usize)), cloning into a move closure inside std::thread::spawn, locking with .lock().unwrap(), and calling handle.join().unwrap().

Loading editor…
Show hint

Create let counter = Arc::new(Mutex::new(0usize)); let cloned = Arc::clone(&counter);, spawn let handle = thread::spawn(move || { let mut guard = cloned.lock().unwrap(); *guard += steps; });, join, and return *counter.lock().unwrap().

Solution available after 3 attempts

Printable Rust Cheatsheet (10 sections)

Complete quick reference covering bindings, ownership, traits, iterators, Cargo tests, and fearless Send/Sync concurrency.

Open cheatsheet

What now?

Keep sharpening your Rust skills locally with `cargo new` and `cargo test`, or test ownership and concurrency patterns directly in the interactive Playground.