Crates.io | non0 |
lib.rs | non0 |
version | 0.1.0 |
source | src |
created_at | 2024-07-09 12:55:39.371332 |
updated_at | 2024-07-09 12:55:39.371332 |
description | Compile-time checked non-zero integers with type inference and first-class `const` support. |
homepage | https://crates.io/crates/non0 |
repository | https://github.com/aatifsyed/non0 |
max_upload_size | |
id | 1297060 |
size | 6,473 |
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
nonzero
uses a proc-macro
that parses the expression passed to it, precluding