Macro static_assertions::const_assert_eq [−][src]
macro_rules! const_assert_eq { ($x:expr, $($xs:expr),+ $(,)*) => { ... }; ($label:ident; $x:expr, $($xs:expr),+ $(,)*) => { ... }; }
Expand description
Asserts that constants are equal in value.
Examples
Works as a shorthand for const_assert!(a == b)
:
const TWO: usize = 2; const_assert_eq!(two; TWO * TWO, TWO + TWO, 4); fn main() { const NUM: usize = 32; const_assert_eq!(NUM + NUM, 64); }
Just because 2 × 2 = 2 + 2 doesn’t mean it holds true for other numbers:
ⓘ
const_assert_eq!(4 + 4, 4 * 4);