rust_silly_mutability.rs (Source)

fn foo<'a>(mut t: &'a i32, v: &'a i32) {
    t = v;
    println!("In foo, t = {}", t);
}

fn bar(t: &mut i32) {
    *t += 1;
    println!("In bar, t = {}", t);
}

fn main() {
    let mut t = 0;
    let v = 42;
    foo(&t, &v);
    bar(&mut t);
    println!("In main, t = {}", t);
}