Created
March 22, 2015 02:10
-
-
Save Manishearth/8bb75bced64e02509c34 to your computer and use it in GitHub Desktop.
Rust swap footgun
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 rockstar_interview_swap(x: &mut u8, y: &mut u8) { | |
// Look, ma, no temporary variables! | |
*x = *x + *y; | |
*y = *x - *y; | |
*x = *x - *y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment