logo
macro_rules! assert_not_impl_all {
    ($x:ty: $($t:path),+ $(,)?) => { ... };
}
Expand description

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

Although u32 implements From<u16>, it does not implement Into<usize>:

assert_not_impl_all!(u32: From<u16>, Into<usize>);

The following example fails to compile since u32 can be converted into u64.

assert_not_impl_all!(u32: Into<u64>);

The following compiles because Cell is not both Sync and Send:

use std::cell::Cell;

assert_not_impl_all!(Cell<u32>: Sync, Send);

But it is Send, so this fails to compile:

assert_not_impl_all!(Cell<u32>: Send);