nonzero_lit

Crates.iononzero_lit
lib.rsnonzero_lit
version0.1.2
sourcesrc
created_at2021-05-02 19:30:49.107905
updated_at2021-05-03 17:11:25.291485
descriptionEasy, safe, and fully zero-cost NonZero constants and literals.
homepagehttps://github.com/thomcc/nonzero_lit
repositoryhttps://github.com/thomcc/nonzero_lit
max_upload_size
id392260
size46,496
crates-io (github:sigp:crates-io)

documentation

https://docs.rs/nonzero_lit

README

nonzero_lit

Build Status Docs Latest Version Minimum Rust Version

A small macro crate providing safe, easy, and fully zero-cost way to construct constant or literal instances of the NonZero* types from core::num.

Features

Usage

Add this to your Cargo.toml:

[dependencies]
nonzero_lit = "0.1"

Examples

let x = nonzero_lit::i32!(4);
assert_eq!(x.get(), 4);
const FERRIS: core::num::NonZeroU32 = nonzero_lit::u32!(0xf34415);
assert_eq!(FERRIS.get(), 0xf34415);
const FERRIS: core::num::NonZeroU32 = nonzero_lit::u32!(0xf34415);
assert_eq!(FERRIS.get(), 0xf34415);

License

Public domain, as explained here. If that's unacceptable, it's also available under either the Apache-2.0 or MIT licenses, at your option.

Commit count: 11

cargo fmt