refactor(lib): use type macro to detect impl Trait

This commit is contained in:
Sean McArthur
2018-08-07 19:39:36 -07:00
parent 9f8add6056
commit 6e8417e08f
7 changed files with 36 additions and 77 deletions

21
src/common/macros.rs Normal file
View File

@@ -0,0 +1,21 @@
#[macro_export]
#[cfg(__hyper_impl_trait_available)]
macro_rules! impl_trait {
(ty: $($t:tt)+) => {
impl $($t)+
};
(e: $e:expr) => {
$e
}
}
#[macro_export]
#[cfg(not(__hyper_impl_trait_available))]
macro_rules! impl_trait {
(ty: $($t:tt)+) => {
Box<$($t)+>
};
(e: $e:expr) => {
Box::new($e)
}
}

View File

@@ -2,6 +2,8 @@ mod buf;
mod exec;
pub(crate) mod io;
mod lazy;
#[macro_use]
mod macros;
mod never;
pub(crate) use self::buf::StaticBuf;