1 | /// A simple `assert` macro that works in `const fn`, for use until the |
2 | /// standard `assert` macro works in `const fn`. |
3 | /// |
4 | /// TODO: With Rust 1.58 we can replace this with just `assert!`. |
5 | #[allow (unused_macros)] |
6 | macro_rules! const_assert { |
7 | ($x:expr) => { |
8 | let b: bool = $x; |
9 | let _ = [()][!b as usize]; |
10 | }; |
11 | } |
12 | |
13 | #[test ] |
14 | #[allow (clippy::missing_const_for_fn)] |
15 | fn test_const_assert() { |
16 | const_assert!(true); |
17 | } |
18 | |
19 | #[test ] |
20 | const fn test_const_assert_in_const_fn() { |
21 | const_assert!(true); |
22 | } |
23 | |