How many mutable references can you have at a time

Rust enforces a rule allowing only one mutable reference to a specific data location at any given time.

You can have only one mutable reference to a particular piece of data at a time. This rule prevents data races by ensuring that no two parts of your code can modify the same data simultaneously.

fn main() {
    let mut s = String::from("hello");
    let r1 = &mut s;
    // let r2 = &mut s; // This would cause a compile error
    println!("{r1}");
}