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.
For (de)serialization with serde, enable the "serde" feature.
For (de)coding with destream, enable the "stream" feature.
Example usage:
let sequence: Vec<Number> = vec![true.into(), 2.into(), 3.5.into(), [1.0, -0.5].into()];
let actual = sequence.into_iter().product();
let expected = Number::from(num::Complex::<f64>::new(7., -3.5));
assert_eq!(expected, actual);
assert_eq!(Int::cast_from(actual), Int::from(7));Structs§
- Boolean
- A boolean value.
- Boolean
Type - The type of a
Boolean. - Complex
Collator - Defines a collation order for
Complex. - Error
- The error type returned when a
Numberoperation fails recoverably. - Float
Collator - Defines a collation order for
Float. - Number
Collator - Defines a collation order for
Number.
Enums§
- Complex
- A complex number.
- Complex
Type - The type of a
Complexnumber. - Float
- A floating-point number.
- Float
Type - The type of a
Float. - Int
- A signed integer.
- IntType
- The type of an
Int. - Number
- A generic number.
- Number
Type - The type of a generic
Number. - UInt
- An unsigned integer.
- UInt
Type - The type of a
UInt.
Traits§
- DType
- Define a
NumberTypefor a non-Numbertype such as a Rust primitive. - Float
Instance - Defines common operations on floating-point numeric types.
- Number
Class - Defines common properties of numeric types supported by
Number. - Number
Instance - Defines common operations on numeric types supported by
Number. - Real
Instance - Defines common operations on real (i.e. not
Complex) numbers. - Trigonometry
- Trigonometric functions.