1 /// A simple static assertion macro. The first argument should be a unique
2 /// ALL_CAPS identifier that describes the condition.
4 #[allow_internal_unstable(type_ascription)]
5 macro_rules! static_assert {
6 ($name:ident: $test:expr) => {
7 // Use the bool to access an array such that if the bool is false, the access
10 static $name: () = [()][!($test: bool) as usize];
14 /// Type size assertion. The first argument is a type and the second argument is its expected size.
16 #[allow_internal_unstable(underscore_const_names)]
17 macro_rules! static_assert_size {
18 ($ty:ty, $size:expr) => {
19 const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];