Step Into Rust · Lesson 4 · Ownership & Types
Structs, Enums & Option
impl blocks, derive, enums that carry data, exhaustive match and Option instead of NULL.
- ~35 minreading and coding
- 4missions
- membersaccess
- Rustlanguage
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
- Structs and methods
- derive
- Enums carry data
- Option: no more NULL
Missions
- A struct with a method
- Debug printing
- An enum with data
- Option instead of NULL