Rust borrowing rules enforce that you can have either one mutable reference or any number of immutable references to a value at a time, but never both simultaneously. This prevents data races by ensuring that while a value is being read, it cannot be changed, and while it is being changed, no one else can read it.
let mut s = String::from("hello");
// Immutable borrow
let r1 = &s;
let r2 = &s;
println!("{}, {}", r1, r2);
// Mutable borrow (immutable borrows must end before this)
let r3 = &mut s;
r3.push_str(", world");
println!("{}", r3);