-
-
Save samueltardieu/004491e7bfd80b701f0cba09a65fff39 to your computer and use it in GitHub Desktop.
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 identity<T>(x: &mut T) -> &mut T { | |
println!("In identity"); | |
x | |
} | |
fn main() { | |
let mut x = 0i32; | |
println!("Before assignment"); | |
*identity(&mut x) = { println!("Evaluating 42"); 42 }; | |
println!("After assignment"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment