Last active
June 5, 2018 19:40
-
-
Save squidarth/e6ecf85eafe2e9d7619f5826708e24cc to your computer and use it in GitHub Desktop.
Demonstration of reborrowing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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