| Crates.io | nzliteral |
| lib.rs | nzliteral |
| version | 1.0.0 |
| created_at | 2025-01-28 05:22:57.744926+00 |
| updated_at | 2025-11-15 05:03:29.46015+00 |
| description | Macro simplifying use of NonZero literals. |
| homepage | |
| repository | https://codeberg.org/gwadej/nzliteral.git |
| max_upload_size | |
| id | 1533265 |
| size | 32,345 |
The NonZero<T> types are really useful for defining variables that cannot be zero. The one
annoying issue I keep running into is creating values from literals that I know cannot be 0, and
still having to unwrap() or expect() to get the resulting NonZero<T> value.
This crate provides the nzliteral macro that fails to compile if it is supplied a 0. If called
with a non-zero literal, the macro creates the NonZero<T> value and automatically unwrap()s it.