Attribute Macro traits

Source
#[traits]
Expand description

Represents the metadata used to conditionally implement one or more traits.

§Arguments

  • traits - one or more traits to add to a super trait.

§Remarks

This attribute is intended to be combined with the cfg_attr attribute to conditionally implement the specified traits. The primary use case is to conditionally add Send and Sync, but any user-specified traits are supported.

§Examples

The following trait only implements Send and Sync when the async feature is activated.

#[cfg_attr(feature = "async", maybe_impl::traits(Send,Sync))]
trait Foo {
   fn bar(&self);
}