Created
September 30, 2015 12:01
-
-
Save anonymous/b2e1b43aab2415932f0b to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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
macro_rules! max { | |
($x:expr) => ( $x ); | |
($x:expr, $($xs:expr),+) => { | |
{ | |
use std::cmp::max; | |
max($x, max!( $($xs),+ )) | |
} | |
}; | |
} | |
macro_rules! min { | |
($x:expr) => ( $x ); | |
($x:expr, $($xs:expr),+) => { | |
{ | |
use std::cmp::min; | |
min($x, min!( $($xs),+ )) | |
} | |
}; | |
} | |
fn main() { | |
println!("{:?}", max!(2, 5, 9, -42, 5)); | |
println!("{:?}", min!(2, 5, 9, -42, 5)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment