1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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); }