The borrow checker is part of Rust’s compiler, rustc. It validates references at compile time to enforce Rust’s memory-management rules, rather than relying on runtime reference counting or garbage collection. section 1.1 section 1.2.1
For a variable or object, the rules are:
- Multiple immutable references are allowed. section 1.2.1
- Only one mutable reference may be active at a time; it cannot overlap with an immutable reference. section 1.2.1
- A reference cannot outlive the variable it refers to. section 1.2.1
Conflicting borrows
`let mut value = String::from("data"); let read = &value; let write = &mut value; println!("{read} {write}");` The mutable and immutable references are both used, so rustc rejects their overlap. Arrange access so conflicting borrows are not active together. section 1.2.1
Treat these compiler checks as a boundary for testing, not a replacement for it. Tests should focus on program logic, failed conversions, stateful operations, and I/O; handle fallible paths explicitly rather than using `unwrap()` or `unsafe` to bypass edge cases. section 6.4



