Created
June 25, 2015 20:42
-
-
Save anonymous/a96b9840c7034540e085 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
#![allow(dead_code)] | |
macro_rules! as_item { ($i:item) => ($i) } | |
macro_rules! s { | |
($t:ident) => { | |
impl $t { | |
} | |
}; | |
($t:ident<$($x:tt),+>) => { | |
as_item!( | |
impl <$($x),+> $t <$($x),+> { | |
} | |
); | |
} | |
} | |
#[derive(Debug)] struct Thing { i: i32 } | |
#[derive(Debug)] struct OtherThing<'a, 'b, T> { p1: &'a i32, p2: &'b i32, t: T } | |
s!(Thing); | |
s!(OtherThing<'a, 'b, T>); | |
fn main() { | |
let a = Thing { i: 42 }; | |
let b = OtherThing { p1: &a.i, p2: &42, t: "moo" }; | |
println!("{:?} {:?}", a, b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment