Pass mutable reference of integer to function
examples/ownership/mutable-integers-in-function/src/main.rs
fn increment(x: &mut i32) { *x += 1; } fn main() { let mut a = 1; println!("{a}"); increment(&mut a); println!("{a}"); }
1 2
fn increment(x: &mut i32) { *x += 1; } fn main() { let mut a = 1; println!("{a}"); increment(&mut a); println!("{a}"); }
1 2