| Crates.io | nonneg-float |
| lib.rs | nonneg-float |
| version | 0.1.0 |
| created_at | 2025-05-22 04:18:03.630648+00 |
| updated_at | 2025-05-22 04:18:03.630648+00 |
| description | A generic NonNegative float wrapper with compile-time checked macro. |
| homepage | |
| repository | https://github.com/martcpp/nonneg-float.git |
| max_upload_size | |
| id | 1684757 |
| size | 37,184 |
A generic Rust crate providing a wrapper for non-negative floating-point numbers with a convenient macro for safe construction.
f32, f64, etc.) implementing num_traits::Float.nonneg! for easy, safe instantiation with optional defaulting to zero.Add this to your Cargo.toml:
[dependencies]
nonneg-float = "0.1.0"
num-traits = "0.2"
fn main() {
let a = nonneg!(f64); // defaults to 0.0
let b = nonneg!(5.5f64); // from literal
let c = nonneg!(f32, 3.14); // explicit type and value
println!("{}, {}, {}", a.get(), b.get(), c.get());
}