Crate qed

source ·
Expand description

Compile time assertions.

This crate contains compile time assertion macros used for maintaining safety invariants or limiting platform support. If the assertion is false, a compiler error is emitted.

Examples

qed::const_assert!(usize::BITS >= u32::BITS);
qed::const_assert_eq!("Veni, vidi, vici".len(), 16);
qed::const_assert_ne!('∎'.len_utf8(), 1);
qed::const_assert_matches!(NonZeroU8::new(42), Some(nz) if nz.get() == 42);

Assertion failures will result in a compile error:

qed::const_assert!("non-empty string".is_empty());

Macros