Defining structs
A struct names a fixed set of fields. `struct User { name: String, age: u32 }` declares a record type with two fields. Construct an instance with `User { name: String::from("Ada"), age: 36 }`.
For deeper background, see the canonical Rust learning roadmap for the broader context behind this section.
Tuple and unit structs
Tuple structs like `struct Point(f32, f32)` give names to coordinate-style records. Unit structs have no fields and are useful as marker types.
impl blocks
Methods live inside `impl` blocks. `impl User { fn is_adult(&self) -> bool { self.age >= 18 } }` adds a method that borrows the user immutably.
Associated functions
Functions in an impl block that don't take `self` are associated functions. `User::new("Ada", 36)` is the conventional constructor pattern in Rust.