1 // SPDX-License-Identifier: GPL-2.0 2 3 //! Static assert. 4 5 /// Static assert (i.e. compile-time assert). 6 /// 7 /// Similar to C11 [`_Static_assert`] and C++1 8 /// 9 /// The feature may be added to Rust in the fu 10 /// 11 /// [`_Static_assert`]: https://en.cppreferenc 12 /// [`static_assert`]: https://en.cppreference 13 /// [RFC 2790]: https://github.com/rust-lang/r 14 /// 15 /// # Examples 16 /// 17 /// ``` 18 /// static_assert!(42 > 24); 19 /// static_assert!(core::mem::size_of::<u8>() 20 /// 21 /// const X: &[u8] = b"bar"; 22 /// static_assert!(X[1] == b'a'); 23 /// 24 /// const fn f(x: i32) -> i32 { 25 /// x + 2 26 /// } 27 /// static_assert!(f(40) == 42); 28 /// ``` 29 #[macro_export] 30 macro_rules! static_assert { 31 ($condition:expr) => { 32 const _: () = core::assert!($condition 33 }; 34 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.