Skip to content

Instantly share code, notes, and snippets.

@swgillespie
Created October 9, 2015 01:49
Show Gist options
  • Save swgillespie/623688b85c3ef90e0319 to your computer and use it in GitHub Desktop.
Save swgillespie/623688b85c3ef90e0319 to your computer and use it in GitHub Desktop.
#![feature(asm)]
fn condition(f: i32) -> bool {
match f {
1 | 2 => opaque(true),
_ => opaque(false)
}
}
#[inline(never)]
fn opaque<T>(thing: T) -> T {
unsafe {
asm!("" : : "r"(&thing))
}
thing
}
fn main() {
let integer = opaque(42);
if condition(integer) {
println!("true")
} else {
println!("false");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment