nonzero

Crates.iononzero
lib.rsnonzero
version0.2.0
sourcesrc
created_at2021-07-24 22:48:29.357821
updated_at2023-08-23 02:26:14.235842
descriptionStatically checked non-zero integers
homepagehttps://github.com/jerry73204/nonzero
repositoryhttps://github.com/jerry73204/nonzero.git
max_upload_size
id426922
size9,198
(jerry73204)

documentation

https://docs.rs/nonzero/

README

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.

Commit count: 8

cargo fmt