Crate number_general[−][src]
Expand description
Provides a generic Number
enum with Boolean
, Complex
, Float
, Int
,
and UInt
variants, as well as a NumberCollator
, ComplexCollator
, and
FloatCollator
since these types do not implement Ord
.
Number
supports casting with safecast
and (de)serialization with serde
.
Example usage:
let sequence: Vec<Number> = serde_json::from_str("[true, 2, 3.5, -4, [1.0, -0.5]]").unwrap(); let actual = sequence.into_iter().product(); let expected = Number::from(num::Complex::<f64>::new(-28., 14.)); assert_eq!(expected, actual); assert_eq!(Int::cast_from(actual), Int::from(-28));
Structs
A boolean value.
The type of a Boolean
.
Defines a collation order for Complex
.
Defines a collation order for Float
.
Defines a collation order for Number
.
A struct for deserializing a Number
which implements
destream::de::Visitor
and serde::de::Visitor
.
Enums
A complex number.
The type of a Complex
number.
A floating-point number.
The type of a Float
.
A signed integer.
The type of an Int
.
A generic number.
The type of a generic Number
.
An unsigned integer.
The type of a UInt
.