Struct dec::OrderedDecimal
source · [−]pub struct OrderedDecimal<D>(pub D);
Expand description
A wrapper for a decimal number that provides an implementation of Ord
and Hash
.
Like the OrderedFloat
type provided by the ordered_float
crate, but
for decimals.
NaN is treated as equal to itself and greater than all non-NaN values. All
other values are compared via their PartialOrd
implementation.
At the moment OrderedDecimal
can only wrap Decimal64
and
Decimal128
. Support for Decimal32
is not planned,
but support for Decimal<N>
would be welcomed, provided a
suitable implementation can be found.
Note that the order used by OrderedDecimal
is not the same as the order
used by the total_cmp
method. The total_cmp
method takes exponents into account and therefore does not consider e.g.
1.2
and 1.20
to be equal.
Tuple Fields
0: D
Implementations
Consumes the ordered decimal wrapper, returning the decimal within.
Trait Implementations
Performs the +=
operation. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the /=
operation. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
type Err = ParseDecimalError
type Err = ParseDecimalError
The associated error which can be returned from parsing.
Parses a string s
to return a value of this type. Read more
Performs the *=
operation. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<'a, D> Product<&'a OrderedDecimal<D>> for OrderedDecimal<D> where
D: Product<&'a D> + 'a,
impl<'a, D> Product<&'a OrderedDecimal<D>> for OrderedDecimal<D> where
D: Product<&'a D> + 'a,
Method which takes an iterator and generates Self
from the elements by
multiplying the items. Read more
Method which takes an iterator and generates Self
from the elements by
multiplying the items. Read more
Performs the %=
operation. Read more
Performs the -=
operation. Read more
Method which takes an iterator and generates Self
from the elements by
“summing up” the items. Read more
Method which takes an iterator and generates Self
from the elements by
“summing up” the items. Read more
Auto Trait Implementations
impl<D> RefUnwindSafe for OrderedDecimal<D> where
D: RefUnwindSafe,
impl<D> Send for OrderedDecimal<D> where
D: Send,
impl<D> Sync for OrderedDecimal<D> where
D: Sync,
impl<D> Unpin for OrderedDecimal<D> where
D: Unpin,
impl<D> UnwindSafe for OrderedDecimal<D> where
D: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more