Macro std::const_assert
Aborts the compilation if cond
evaluates to false during compilation.
cond
must be a constant expression.
Examples
use std::const_assert;
use std::mem::size_of;
// Check we are not compiling for a 16-bit system
const_assert!(size_of::<usize>() > 2);
Run this example
use std::const_assert;
use std::mem::size_of;
const_assert!(size_of::<i32>() < size_of::<i16>()); // fails to compile
Run this example