Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chapter 2: Advanced Notes

This chapter covers more complex note content.

Notes with code blocks

The Iterator trait

1
#![allow(unused)]
fn main() {
pub trait Iterator {
    type Item;
    fn next(&mut self) -> Option<Self::Item>;
}
}

The heart of Rust's iterator system — just one required method.

powers Rust’s functional programming patterns.

Notes with lists

Error handling in Rust

2

Common patterns:

  • Recoverable: Result<T, E> with ? operator
  • Unrecoverable: panic! macro
  • Optional values: Option<T> with ? operator (in functions returning Option)

Choose the right tool for the situation.

is versatile and explicit.

Notes with blockquotes

The module system

3

Modules let you organize code within a crate into groups for readability and reuse. They also control the privacy of items: public, private, or pub(crate).

See The Book.

helps organize large codebases.

Clippy4Run cargo clippy to get lint suggestions. Configure with #[allow(clippy::some_lint)] attributes. See the Clippy Lints page. catches common mistakes.

Notes with tables

Rust edition differences

5
EditionYearKey Feature
20152015Original
20182018NLL, dyn Trait
20212021Closure captures
20242024gen blocks

can trip up newcomers.