Crate number_general[−][src]
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
Boolean | A boolean value. |
BooleanType | The type of a |
ComplexCollator | Defines a collation order for |
FloatCollator | Defines a collation order for |
NumberCollator | Defines a collation order for |
NumberVisitor | A struct for deserializing a |
Enums
Complex | A complex number. |
ComplexType | The type of a |
Float | A floating-point number. |
FloatType | The type of a |
Int | A signed integer. |
IntType | The type of an |
Number | A generic number. |
NumberType | The type of a generic |
UInt | An unsigned integer. |
UIntType | The type of a |
Traits
NumberClass | Defines common properties of numeric types supported by |
NumberInstance | Defines common operations on numeric types supported by |