Created
September 17, 2013 03:19
-
-
Save MarkJr94/6589689 to your computer and use it in GitHub Desktop.
Conditional compilation/execution
This file contains 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 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