Crates.io | nzliteral |
lib.rs | nzliteral |
version | |
source | src |
created_at | 2025-01-28 05:22:57.744926 |
updated_at | 2025-01-31 02:09:37.915465 |
description | Macro simplifying use of NonZero literals. |
homepage | |
repository | https://gitlab.com/gwadej/nzliteral.git |
max_upload_size | |
id | 1533265 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.