Macro uniffi::deps::static_assertions::assert_not_impl_any
source · macro_rules! assert_not_impl_any { ($x:ty: $($t:path),+ $(,)?) => { ... }; }
Expand description
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 impl
s.
This macro causes a compilation failure 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
If u32
were to implement Into
conversions for usize
and for u8
,
the following would fail to compile:
assert_not_impl_any!(u32: Into<usize>, Into<u8>);
This is also good for simple one-off cases:
assert_not_impl_any!(&'static mut u8: Copy);
The following example fails to compile since u32
can be converted into
u64
even though it can not be converted into a u16
:
ⓘ
assert_not_impl_any!(u32: Into<u64>, Into<u16>);