non0

Crates.ionon0
lib.rsnon0
version0.1.0
sourcesrc
created_at2024-07-09 12:55:39.371332
updated_at2024-07-09 12:55:39.371332
descriptionCompile-time checked non-zero integers with type inference and first-class `const` support.
homepagehttps://crates.io/crates/non0
repositoryhttps://github.com/aatifsyed/non0
max_upload_size
id1297060
size6,473
Aatif Syed (aatifsyed)

documentation

https://docs.rs/non0

README

Compile-time checked non-zero integers with type inference and first-class const support.

const UNSIGNED: NonZeroUsize = nonzero!(1);
const SIGNED: NonZeroI8 = nonzero!(-1);
           // ^ correctly infers return type

const MY_CONST: usize = 20;
const MY_NONZERO_CONST: NonZeroUsize = nonzero!(MY_CONST - 19);
              // refer to other constant values ^
let runtime = nonzero!(0); // eager evaluation

Comparison with other libraries

  • nonzero uses a proc-macro that parses the expression passed to it, precluding
    • Type inference.
    • Referencing constants.
Commit count: 11

cargo fmt