Macro static_assertions::assert_impl_all [−][src]
macro_rules! assert_impl_all { ($($xs:tt)+) => { ... }; }
Expand description
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 impl
s.
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:
ⓘ
#![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:
ⓘ
assert_impl_all!(*const u8, Send);