Skip to content

Instantly share code, notes, and snippets.

Created April 6, 2016 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3eea892a079a1884849113e6892443d6 to your computer and use it in GitHub Desktop.
Save anonymous/3eea892a079a1884849113e6892443d6 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
macro_rules! foo {
($trait_:ident) => { foo! { $trait_<> } };
($trait_:ident < $($args:ident),* $(,)* >) => {
impl $trait_ {
pub fn bar<T: $trait_<$($args)*>>(&self) {}
}
};
}
trait Trait1 {}
trait Trait2<T> {}
foo!(Trait1);
foo!(Trait2<T>); // error: no rules expected the token `<`
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment