1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// run-pass macro_rules! test { ( fn fun() -> Option<Box<$t:ty>>; ) => { fn fun(x: $t) -> Option<Box<$t>> { Some(Box::new(x)) } } } test! { fn fun() -> Option<Box<i32>>; } fn main() { println!("{}", fun(0).unwrap()); }