trait_set!() { /* proc-macro */ }
Expand description
Creates an alias for set of traits.
To demonstrate the idea, see the examples:
use trait_set::trait_set;
trait_set! {
/// Doc-comments are also supported btw.
pub trait ThreadSafe = Send + Sync;
pub trait ThreadSafeIterator<T> = ThreadSafe + Iterator<Item = T>;
pub trait ThreadSafeBytesIterator = ThreadSafeIterator<u8>;
pub trait StaticDebug = 'static + std::fmt::Debug;
}
This macro also supports higher-rank trait bound:
use trait_set::trait_set;
trait_set!{
pub trait Serde = Serialize + for<'de> Deserialize<'de>;
// Note that you can also use lifetimes as a generic parameter.
pub trait SerdeLifetimeTemplate<'de> = Serialize + Deserialize<'de>;
}