[−][src]Macro static_assertions::assert_impl_one
Asserts that the type implements exactly one in a set of traits.
Related:
Examples
Given some type Foo, it is expected to implement either Snap, Crackle,
or Pop:
ⓘThis example deliberately fails to compile
struct Foo; trait Snap {} trait Crackle {} trait Pop {} assert_impl_one!(Foo: Snap, Crackle, Pop);
If only Crackle is implemented, the assertion passes:
impl Crackle for Foo {} assert_impl_one!(Foo: Snap, Crackle, Pop);
If Snap or Pop is also implemented, the assertion fails:
ⓘThis example deliberately fails to compile
impl Pop for Foo {} assert_impl_one!(Foo: Snap, Crackle, Pop);