Compile-time checked non-zero integers with type inference and first-class const support.
const UNSIGNED: NonZeroUsize = nonzero!;
const SIGNED: NonZeroI8 = nonzero!;
// ^ correctly infers return type
const MY_CONST: usize = 20;
const MY_NONZERO_CONST: NonZeroUsize = nonzero!;
// refer to other constant values ^
let runtime = nonzero!; // eager evaluation
Comparison with other libraries
nonzerouses a proc-macro that parses the expression passed to it, precluding- Type inference.
- Referencing constants.