borrowing

Lifetime annotations for flexible borrowing in structs

When a struct holds a reference, you must annotate its lifetime so the compiler knows the reference won't outlive the data. The syntax <'a> declares a lifetime parameter, and &'a str ties the reference to that lifetime. This ensures that as

Borrowing with & and &mut for zero-cost access

Instead of transferring ownership, Rust lets you borrow values with references (&T for immutable, &mut T for mutable). Borrows allow functions to read or modify data without taking ownership, so the caller retains access afterward. The borrow