Created
July 1, 2019 23:36
-
-
Save peterjoel/9607ae3fbc1a067caa13c057970bf92d 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
trait Trait { | |
fn p(&self); | |
} | |
macro_rules! m { | |
($v: expr, $t: ty, $n: literal) => { | |
impl Trait for $t { | |
fn p(&self) { | |
print!($n); | |
} | |
} | |
$v.p(); | |
} | |
} | |
fn main() { | |
m!((0), (i32), "1"); | |
m!((0,), (u32,), "2"); | |
m!((0, 0), (i32, i32), "3"); | |
m!((0, 0,), (u32, i32,), "4"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment