number-general

Crates.ionumber-general
lib.rsnumber-general
version0.12.0
sourcesrc
created_at2021-01-05 04:51:49.513592
updated_at2024-08-13 22:44:13.553075
descriptionA generic number type for Rust which supports basic math and (de)serialization.
homepage
repositoryhttps://github.com/haydnv/number-general.git
max_upload_size
id331911
size136,847
Haydn Vestal (haydnv)

documentation

README

number-general

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));
Commit count: 80

cargo fmt