2 unstable releases

0.2.0 Aug 23, 2023
0.1.0 Jul 24, 2021

#37 in #checked

Download history 504/week @ 2024-11-19 361/week @ 2024-11-26 238/week @ 2024-12-03 447/week @ 2024-12-10 420/week @ 2024-12-17 251/week @ 2024-12-24 208/week @ 2024-12-31 426/week @ 2025-01-07 423/week @ 2025-01-14 405/week @ 2025-01-21 447/week @ 2025-01-28 424/week @ 2025-02-04 372/week @ 2025-02-11 406/week @ 2025-02-18 498/week @ 2025-02-25 660/week @ 2025-03-04

2,000 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

~305–800KB
~18K SLoC