[][src]Macro static_assertions::assert_not_impl_any

macro_rules! assert_not_impl_any {
    ($($xs:tt)+) => { ... };
}

Asserts that the type does not implement any 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.

The result of the macro fails to compile if any of the provided individual traits are implemented for the type. If you want to check that a combination of traits is not implemented you should invoke assert_not_impl_all! instead. For single traits both macros behave the same.

Examples

On stable Rust, using the macro requires a unique “label” when used in a module scope:

assert_not_impl_any!(ptr0; *const u16, Send);
assert_not_impl_any!(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_any!(&'static mut u8, Copy);

fn main() {
    assert_not_impl_any!(u32, Into<usize>);
}

The following example fails to compile since u32 can be converted into u64 even though it can not be converted into a u16.

This example deliberately fails to compile
assert_not_impl_any!(u32, Into<u64>, Into<u16>);