Skip to content

Instantly share code, notes, and snippets.

@peterjoel
Created July 1, 2019 23:36
Show Gist options
  • Save peterjoel/9607ae3fbc1a067caa13c057970bf92d to your computer and use it in GitHub Desktop.
Save peterjoel/9607ae3fbc1a067caa13c057970bf92d to your computer and use it in GitHub Desktop.
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