Skip to content

Instantly share code, notes, and snippets.

@miquels
Last active September 19, 2018 22:07
Show Gist options
  • Save miquels/51252cdfddc49d952600938dcb8f0e9d to your computer and use it in GitHub Desktop.
Save miquels/51252cdfddc49d952600938dcb8f0e9d to your computer and use it in GitHub Desktop.
Rust trait alias macro
extern crate futures;
use futures::prelude::*;
use std::io;
macro_rules! trait_alias {
($alias:ident = $($trait_:tt)*) => {
trait $alias: $($trait_)* {}
impl<T: $($trait_)*> $alias for T {}
}
}
trait_alias!(AliasName = Future<Item=(), Error=io::Error>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment