macro_rules! build_assert_ne {
    ($left:expr, $right:expr $(,)?) => { ... };
    ($left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that two expressions are not equal to each other at build-time (using PartialEq).

In release mode, if the expression is evaluated to false, or the compiler or optimizer cannot ensure that the expression is evaluated to true, this macro will stop the compilation process.

In debug mode, if the expression is evaluated to false, this macro will panic.

Examples

fn foo<const A: usize, const B: usize>() {
  build_assert_ne!(A, B, "A and B are equal");
}

foo::<1, 2>(); // Fine.
foo::<1, 1>(); // Fails to compile in release mode, panics in debug mode.