Skip to main content
eLearner.app

End of the Rust Course

Summary and final challenge

Congratulations: you have made it through the 4 modules of the Rust Course — from your very first variables and default immutability to ownership, borrowing, and implementing methods on structs. Below is a map of everything you have mastered and a three-step final challenge.

Reminder: Rust exercises are verified statically (keywords). To actually run the code, each exercise provides a Rust Playground button that copies the code and opens play.rust-lang.org.

01 · Fundamentals

  • variables
  • let / let mut / const
  • shadowing
  • primitive types
  • tuples / arrays

02 · Control flow

  • if / else
  • if as expression
  • loop
  • while
  • for and range
  • match

03 · Ownership and Borrowing

  • ownership
  • stack and heap
  • move
  • references &
  • mutable borrowing &mut

04 · Structs and Methods

  • structs
  • instances
  • impl methods
  • associated functions (new)

The final challenge, in three steps

Combine what you have learned about Rust by building three small logical components: a boolean checker, an in-place modification using pass-by-mutable-reference, and a struct that encapsulates a count value.

1 · Even/odd check

Write a function that accepts a 32-bit integer and returns true if it is even, false otherwise. Module 1 (operators) + Module 2 (functions).

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

Define the function is_even(n: i32) -> bool that returns a boolean value indicating if the passed number is even (n % 2 == 0).

Loading editor…
Show hint

Use the return type -> bool and the modulo operator (%). Example: n % 2 == 0

Solution available after 3 attempts

2 · Double and square by mutable reference

Write a function that receives a mutable reference to an integer and squares it directly in the original variable. Module 3 (pass-by-mutable-reference).

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

Define the function square_by_ref(n: &mut i32) that accepts a mutable reference to an integer and calculates its square in-place, dereferencing n to modify it.

Loading editor…
Show hint

Inside the function write *n = *n * *n; to access and modify the value pointed to by the reference.

Solution available after 3 attempts

3 · Encapsulated Counter Struct

Create a struct with private fields that provides public methods to initialize the value to 0, increment it, and read it. Module 4 (structs and methods).

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

Complete the implementation of Counter by defining pub fn new() -> Counter returning Counter with count at 0, pub fn increment(&mut self) incrementing count by 1, and pub fn get_count(&self) -> u32 returning count.

Loading editor…
Show hint

Use the pub keyword to make the methods accessible outside of the impl block.

Solution available after 3 attempts

Printable Cheatsheet

A single page with all the essential syntax of modern Rust, ready to keep handy while you code.

Open the cheatsheet

What now?

Consistent practice is the best way to strengthen your skills. Open the Rust Playground to experiment freely with complex scenarios or to prepare your code snippets before testing them on a real compiler.