Step Into Labs

Step Into Rust · Lesson 4 · Ownership & Types

Structs, Enums & Option

impl blocks, derive, enums that carry data, exhaustive match and Option instead of NULL.

Part of Step Into Rust. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.

&self borrows the struct, &mut self borrows it mutably, and plain self takes ownership.

In this lesson

Missions

  1. A struct with a method
  2. Debug printing
  3. An enum with data
  4. Option instead of NULL