[−][src]Macro static_assertions::assert_impl_all
Asserts that the type implements all of the given traits.
This can be used to ensure types implement auto traits such as Send and
Sync, as well as traits with blanket impls.
Examples
On stable Rust, using the macro requires a unique “label” when used in a module scope:
assert_impl_all!(str; String, Send, Sync, From<&'static str>); assert_impl_all!(vec; &'static [u8], Into<Vec<u8>>);
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_impl_all!(u32, Copy, Send); fn main() { assert_impl_all!(&str, Into<String>); }
Raw pointers cannot be sent between threads safely:
ⓘThis example deliberately fails to compile
assert_impl_all!(*const u8, Send);