mod stubbing; mod ignore; mod utils; #[cfg(feature = "debugging")] pub mod debugging; pub use proc_macro2::TokenStream; /// A trait that allows for conversion both ways between two types. pub trait BothWays: From + Into {} /// A trait that allows for conversion between two types, but only if the intermediate type can be converted into the target type. pub trait SomehowInto>: Into { fn somehow(self) -> T { self.into().into() } } /// Ignores the input and returns an empty token stream. pub fn ignore>(_cfg: T, input: T) -> T { ignore::ignore(input.into()).into() } pub fn stub>(_cfg: T, input: T) -> T { use syn::*; let input = input.into(); if let Ok(f) = syn::parse2::(input.clone()) { return stubbing::stub_function(f).somehow(); } if let Ok(f) = syn::parse2::(input.clone()) { return stubbing::stub_function(f).somehow(); } if let Ok(i) = syn::parse2::(input.clone()) { return stubbing::stub_impl(i).somehow(); } panic!("Unable to stub that thing!"); } impl BothWays for T where T: From + Into {} impl SomehowInto for T where T: Into, I: Into {}