Перейти к основному содержимому

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).

Упражнение#rust.boss.e1
Попыток: 0Загрузка…

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

Загрузка редактора…
Показать подсказку

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

Решение доступно после 3 попыток

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).

Упражнение#rust.boss.e2
Попыток: 0Загрузка…

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.

Загрузка редактора…
Показать подсказку

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

Решение доступно после 3 попыток

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).

Упражнение#rust.boss.e3
Попыток: 0Загрузка…

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.

Загрузка редактора…
Показать подсказку

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

Решение доступно после 3 попыток

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.