Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 11, 2019 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/4eb7efb7c8fb78f939465580536585a0 to your computer and use it in GitHub Desktop.
Save rust-play/4eb7efb7c8fb78f939465580536585a0 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let mut x = 41;
x ^= 1;
for i in 0..(std::mem::size_of::<usize>()*8) {
if x & (1 << i) == 0 { x ^= 1 << (i+1); } else { break; }
}
println!("{}", x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment