2 unstable releases
0.2.0 | Aug 23, 2023 |
---|---|
0.1.0 | Jul 24, 2021 |
#32 in #checked
1,695 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
~290–780KB
~17K SLoC