Skip to content

Instantly share code, notes, and snippets.

@squidarth
Last active June 5, 2018 19:40
Show Gist options
  • Save squidarth/e6ecf85eafe2e9d7619f5826708e24cc to your computer and use it in GitHub Desktop.
Save squidarth/e6ecf85eafe2e9d7619f5826708e24cc to your computer and use it in GitHub Desktop.
Demonstration of reborrowing
fn incr_int(a: &mut u32) {
*a += 1;
}
fn main() {
let mut a = 42;
let mut_ref = &mut a;
incr_int(&mut *mut_ref);
incr_int(&mut *mut_ref);
println!("{}", *mut_ref);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment