Macro nonzero_lit::i16 [−][src]
macro_rules! i16 { ($val:expr $(,)?) => { ... }; }
Create a literal NonZeroI16
.
Examples
Basic usage
let x = nonzero_lit::i16!(4); assert_eq!(x.get(), 4);
Works for consts, and the parameter can be any const expression (not just a literal).
const A: i16 = 5; const B: core::num::NonZeroI16 = nonzero_lit::i16!(A * 10); assert_eq!(B.get(), 50);
Misuse is detected at compile time.
ⓘ
const ZERO: core::num::NonZeroI16 = nonzero_lit::i16!(0);
Even if dodgy code tries to #[allow(...)]
it.
ⓘ
#[allow(const_err)] const ZERO: core::num::NonZeroI16 = nonzero_lit::i16!(0);
Note: argument must be a constant expression.
ⓘ
let bar = 3; let foo = nonzero_lit::i16!(bar);