non0 0.1.0

Compile-time checked non-zero integers with type inference and first-class `const` support.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 7.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 571.8 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • aatifsyed/non0
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aatifsyed

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.