2 unstable releases

0.2.0 Aug 23, 2023
0.1.0 Jul 24, 2021

#32 in #checked

Download history 322/week @ 2024-10-16 407/week @ 2024-10-23 383/week @ 2024-10-30 471/week @ 2024-11-06 422/week @ 2024-11-13 437/week @ 2024-11-20 320/week @ 2024-11-27 253/week @ 2024-12-04 483/week @ 2024-12-11 358/week @ 2024-12-18 262/week @ 2024-12-25 288/week @ 2025-01-01 369/week @ 2025-01-08 411/week @ 2025-01-15 423/week @ 2025-01-22 374/week @ 2025-01-29

1,695 downloads per month
Used in 2 crates (via fusion-blossom)

MIT license

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.

[ docs.rs | crates.io ]

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