2 unstable releases
0.2.0 | Aug 23, 2023 |
---|---|
0.1.0 | Jul 24, 2021 |
1,721 downloads per month
Used in 2 crates
(via fusion-blossom)
7KB
167 lines
nonzero: Statically Checked Non-Zero Integers
The crate provides the nonzero!
macro that converts an integer to NonZero{Usize,Isize,...}
types. The conversion is done statically without extra runtime cost, and rejects zeros in compile-time.
Example
use nonzero::nonzero as nz;
use std::num::{NonZeroI32, NonZeroUsize};
let safe_seven: NonZeroUsize = nz!(7usize);
let negative_one: NonZeroI32 = nz!(-1i32);
License
MIT license. See license file.
Dependencies
~0.3–0.8MB
~18K SLoC