Skip to content

Instantly share code, notes, and snippets.

@MarkJr94
Created September 17, 2013 03:19
Show Gist options
  • Save MarkJr94/6589689 to your computer and use it in GitHub Desktop.
Save MarkJr94/6589689 to your computer and use it in GitHub Desktop.
Conditional compilation/execution
fn mutate(x: &mut int) -> int {
let ret = x.clone();
*x += 100;
ret
}
fn main() {
let mut x = -5;
x += 5;
debug!("Original value of x: %d", mutate(&mut x));
println!("Final value of x: {0:d}", x);
}
// Compilation command:
rustc test.rs --cfg debug
// Execution command A:
RUST_LOG=test=4 ./test
// Execution result A:
Original value of x: 0
Final value of x: 100
// Execution command B:
./test
// Execution result B:
Final value of x: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment