| Crates.io | nzliteral |
| lib.rs | nzliteral |
| version | 0.6.0 |
| created_at | 2025-01-28 05:22:57.744926+00 |
| updated_at | 2025-05-21 02:56:27.630913+00 |
| description | Macro simplifying use of NonZero literals. |
| homepage | |
| repository | https://codeberg.org/gwadej/nzliteral.git |
| max_upload_size | |
| id | 1533265 |
| size | 32,526 |
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.