Created
October 4, 2014 18:41
-
-
Save little-arhat/88e34b5ccc0024a36a48 to your computer and use it in GitHub Desktop.
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
#![feature(macro_rules)] | |
macro_rules! iter_magic( | |
($inp:expr => $($func:ident ($args:expr))=>+) => ( | |
$inp.iter()$(.$func($args))+ | |
); | |
) | |
fn main() { | |
let b = "hello".as_bytes(); | |
for c in iter_magic!(b => | |
map(|x| x) => | |
filter(|&x| x % 2 == 0 ) | |
) { | |
println!("{}", c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment