[−][src]Macro static_assertions::assert_not_impl_all
Asserts that the type does not implement all of the given traits.
This can be used to ensure types do not implement auto traits such as
Send and Sync, as well as traits with blanket impls.
Note that the combination of all provided traits is required to not be
implemented. If you want to check that none of multiple traits are
implemented you should invoke assert_not_impl_any! instead.
Examples
On stable Rust, using the macro requires a unique “label” when used in a module scope:
assert_not_impl_all!(ptr0; *const u16, Send, Sync); assert_not_impl_all!(ptr1; *const u8, Send, Sync);
The labeling limitation is not necessary if
compiling on nightly Rust with the nightly feature enabled:
ⓘThis example is not tested
#![feature(underscore_const_names)] assert_not_impl_all!(&'static mut u8, Copy); fn main() { assert_not_impl_all!(u32, Into<usize>); }
The following example fails to compile since u32 can be converted into
u64.
ⓘThis example deliberately fails to compile
assert_not_impl_all!(u32, Into<u64>);
Cell<u32> is not both Sync and Send.
assert_not_impl_all!(cell; Cell<u32>, Sync, Send);
But it is Send, so this fails to compile.
ⓘThis example deliberately fails to compile
assert_not_impl_all!(cell; Cell<u32>, Send);