logo
macro_rules! const_assert_eq {
    ($x:expr, $y:expr $(,)?) => { ... };
}
Expand description

Asserts that constants are equal in value.

Examples

This works as a shorthand for const_assert!(a == b):

const TWO: usize = 2;

const_assert_eq!(TWO * TWO, TWO + TWO);

Just because 2 × 2 = 2 + 2 doesn’t mean it holds true for other numbers:

const_assert_eq!(4 + 4, 4 * 4);