Chapter 1: Getting Started
Welcome to the demo of mdbook-inplace-notes!
Simple inline notes
The HashMap type1A hash map implemented with quadratic probing and
SIMD lookup. See std::collections
for details. is Rust’s standard key-value store.
Here’s a Vec2A contiguous, growable array type, written Vec<T>. It
allocates on the heap and provides O(1) indexing. — the most common collection.
Notes with inline formatting
The ? operator3The ? operator is syntactic sugar for propagating
errors. It’s equivalent to match with early return on Err. simplifies error
handling in Rust.
Use cargo build --release4The –release flag enables optimizations
(equivalent to opt-level = 3 in Cargo.toml). Builds are slower but runtime is
much faster. for production builds.
Notes with block content
Ownership in Rust
Rust's ownership rules:
- Each value has exactly one owner
- When the owner goes out of scope, the value is dropped
- Values can be moved or borrowed
See The Book for more.
is what makes Rust unique.
Multiple notes in one paragraph
Rust has several string6String is an owned, heap-allocated, growable
UTF-8 string. types7&str is a borrowed string slice pointing to
valid UTF-8 data. for different use cases.
Chapter 2: Advanced Notes
This chapter covers more complex note content.
Notes with code blocks
The Iterator trait
#![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
Common patterns:
- Recoverable:
Result<T, E>with?operator - Unrecoverable:
panic!macro - Optional values:
Option<T>with?operator (in functions returningOption)
Choose the right tool for the situation.
is versatile and explicit.
Notes with blockquotes
The module system
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.
Notes with inline code and links
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
| Edition | Year | Key Feature |
|---|---|---|
| 2015 | 2015 | Original |
| 2018 | 2018 | NLL, dyn Trait |
| 2021 | 2021 | Closure captures |
| 2024 | 2024 | gen blocks |
can trip up newcomers.