Crates.io | number-general |
lib.rs | number-general |
version | 0.12.0 |
source | src |
created_at | 2021-01-05 04:51:49.513592 |
updated_at | 2024-08-13 22:44:13.553075 |
description | A generic number type for Rust which supports basic math and (de)serialization. |
homepage | |
repository | https://github.com/haydnv/number-general.git |
max_upload_size | |
id | 331911 |
size | 136,847 |
A generic Rust number type with support for basic math operations, (de)serialization, and casting with safecast.
Example usage:
use number_general::{Int, Number};
use safecast::CastFrom;
let sequence: Vec<Number> = serde_json::from_str("[true, 2, 3.5, -4, [1.0, -0.5]]").unwrap();
let actual = sequence.into_iter().product();
assert_eq!(actual, Number::from(num::Complex::<f64>::new(-28., 14.)));
assert_eq!(Int::cast_from(actual), Int::from(-28));