nzliteral

Crates.ionzliteral
lib.rsnzliteral
version0.6.0
created_at2025-01-28 05:22:57.744926+00
updated_at2025-05-21 02:56:27.630913+00
descriptionMacro simplifying use of NonZero literals.
homepage
repositoryhttps://codeberg.org/gwadej/nzliteral.git
max_upload_size
id1533265
size32,526
G. Wade Johnson (gwadej)

documentation

README

nzliteral

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.

Commit count: 0

cargo fmt