nz (non-zero)
The nz crate provides a collection of user-friendly macros that simplify the creation
of new instances of non-zero numeric types found in the [core::num]. With these macros,
you can effortlessly generate instances using numeric literals, constant values and
constant expressions, all at compile time.
Features
- No unsafe code
- No dependencies
no_stdcompatible- Supports all numeric non-zero types from the [
core::num] module - Compile time evaluation
- Zero detection at compile time
NonZero macros
Basic usage
use NonZeroU8;
const NZ_U8_MIN: NonZeroU8 = u8!; // with numeric literal
const NZ_U8_MAX: NonZeroU8 = u8!; // with constant value
let sum = u8!; // with constant expression
Remarks
Non-zero macros cannot be used with constant function arguments as they are not constant values.
Example
use NonZeroU64;
const
let nz = wrapping_add_nz;