Last active
September 19, 2018 22:07
-
-
Save miquels/51252cdfddc49d952600938dcb8f0e9d to your computer and use it in GitHub Desktop.
Rust trait alias macro
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
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