Struct dec::OrderedDecimal [−][src]
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.
Implementations
impl<D> OrderedDecimal<D>
[src]
pub fn into_inner(self) -> D
[src]
Consumes the ordered decimal wrapper, returning the decimal within.
Trait Implementations
impl<D> Add<D> for OrderedDecimal<D> where
D: Add<Output = D>,
[src]
D: Add<Output = D>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: D) -> Self
[src]
impl<D> Add<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Add<Output = D>,
[src]
D: Add<Output = D>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: OrderedDecimal<D>) -> Self
[src]
impl Add<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl Add<OrderedDecimal<Decimal64>> for Decimal64
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: OrderedDecimal<Decimal64>) -> Self
[src]
impl<D> AddAssign<D> for OrderedDecimal<D> where
D: Add<Output = D> + Copy,
[src]
D: Add<Output = D> + Copy,
Adds inner directly.
fn add_assign(&mut self, other: D)
[src]
impl<D> AddAssign<OrderedDecimal<D>> for OrderedDecimal<D> where
D: AddAssign,
[src]
D: AddAssign,
fn add_assign(&mut self, other: Self)
[src]
impl<D: Clone> Clone for OrderedDecimal<D>
[src]
fn clone(&self) -> OrderedDecimal<D>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<D: Copy> Copy for OrderedDecimal<D>
[src]
impl<D: Debug> Debug for OrderedDecimal<D>
[src]
impl<D> Default for OrderedDecimal<D> where
D: Default,
[src]
D: Default,
impl<D> Display for OrderedDecimal<D> where
D: Display,
[src]
D: Display,
impl<D> Div<D> for OrderedDecimal<D> where
D: Div<Output = D>,
[src]
D: Div<Output = D>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: D) -> Self
[src]
impl<D> Div<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Div<Output = D>,
[src]
D: Div<Output = D>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: OrderedDecimal<D>) -> Self
[src]
impl Div<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl Div<OrderedDecimal<Decimal64>> for Decimal64
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: OrderedDecimal<Decimal64>) -> Self
[src]
impl<D> DivAssign<D> for OrderedDecimal<D> where
D: Div<Output = D> + Copy,
[src]
D: Div<Output = D> + Copy,
Divs inner directly.
fn div_assign(&mut self, other: D)
[src]
impl<D> DivAssign<OrderedDecimal<D>> for OrderedDecimal<D> where
D: DivAssign,
[src]
D: DivAssign,
fn div_assign(&mut self, other: Self)
[src]
impl<D> Eq for OrderedDecimal<D> where
Self: Ord,
[src]
Self: Ord,
impl<D> From<Decimal128> for OrderedDecimal<D> where
D: From<Decimal128>,
[src]
D: From<Decimal128>,
fn from(n: Decimal128) -> OrderedDecimal<D>
[src]
impl<D> From<Decimal32> for OrderedDecimal<D> where
D: From<Decimal32>,
[src]
D: From<Decimal32>,
fn from(n: Decimal32) -> OrderedDecimal<D>
[src]
impl<D> From<Decimal64> for OrderedDecimal<D> where
D: From<Decimal64>,
[src]
D: From<Decimal64>,
fn from(n: Decimal64) -> OrderedDecimal<D>
[src]
impl<D> From<i32> for OrderedDecimal<D> where
D: From<i32>,
[src]
D: From<i32>,
fn from(n: i32) -> OrderedDecimal<D>
[src]
impl<D> From<u32> for OrderedDecimal<D> where
D: From<u32>,
[src]
D: From<u32>,
fn from(n: u32) -> OrderedDecimal<D>
[src]
impl<D> FromStr for OrderedDecimal<D> where
D: FromStr<Err = ParseDecimalError>,
[src]
D: FromStr<Err = ParseDecimalError>,
type Err = ParseDecimalError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<OrderedDecimal<D>, ParseDecimalError>
[src]
impl Hash for OrderedDecimal<Decimal64>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Hash for OrderedDecimal<Decimal128>
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<D> Mul<D> for OrderedDecimal<D> where
D: Mul<Output = D>,
[src]
D: Mul<Output = D>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: D) -> Self
[src]
impl<D> Mul<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Mul<Output = D>,
[src]
D: Mul<Output = D>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: OrderedDecimal<D>) -> Self
[src]
impl Mul<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl Mul<OrderedDecimal<Decimal64>> for Decimal64
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: OrderedDecimal<Decimal64>) -> Self
[src]
impl<D> MulAssign<D> for OrderedDecimal<D> where
D: Mul<Output = D> + Copy,
[src]
D: Mul<Output = D> + Copy,
Muls inner directly.
fn mul_assign(&mut self, other: D)
[src]
impl<D> MulAssign<OrderedDecimal<D>> for OrderedDecimal<D> where
D: MulAssign,
[src]
D: MulAssign,
fn mul_assign(&mut self, other: Self)
[src]
impl<D> Neg for OrderedDecimal<D> where
D: Neg<Output = D>,
[src]
D: Neg<Output = D>,
impl Ord for OrderedDecimal<Decimal64>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl Ord for OrderedDecimal<Decimal128>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<D> PartialEq<OrderedDecimal<D>> for OrderedDecimal<D> where
Self: Ord,
[src]
Self: Ord,
impl<D> PartialOrd<OrderedDecimal<D>> for OrderedDecimal<D> where
Self: Ord,
[src]
Self: Ord,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, D> Product<&'a OrderedDecimal<D>> for OrderedDecimal<D> where
D: Product<&'a D> + 'a,
[src]
D: Product<&'a D> + 'a,
fn product<I>(iter: I) -> Self where
I: Iterator<Item = &'a OrderedDecimal<D>>,
[src]
I: Iterator<Item = &'a OrderedDecimal<D>>,
impl<D> Product<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Product,
[src]
D: Product,
fn product<I>(iter: I) -> Self where
I: Iterator<Item = OrderedDecimal<D>>,
[src]
I: Iterator<Item = OrderedDecimal<D>>,
impl<D> Rem<D> for OrderedDecimal<D> where
D: Rem<Output = D>,
[src]
D: Rem<Output = D>,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: D) -> Self
[src]
impl<D> Rem<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Rem<Output = D>,
[src]
D: Rem<Output = D>,
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: OrderedDecimal<D>) -> Self
[src]
impl Rem<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl Rem<OrderedDecimal<Decimal64>> for Decimal64
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: OrderedDecimal<Decimal64>) -> Self
[src]
impl<D> RemAssign<D> for OrderedDecimal<D> where
D: Rem<Output = D> + Copy,
[src]
D: Rem<Output = D> + Copy,
Rems inner directly.
fn rem_assign(&mut self, other: D)
[src]
impl<D> RemAssign<OrderedDecimal<D>> for OrderedDecimal<D> where
D: RemAssign,
[src]
D: RemAssign,
fn rem_assign(&mut self, other: Self)
[src]
impl<D> Sub<D> for OrderedDecimal<D> where
D: Sub<Output = D>,
[src]
D: Sub<Output = D>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: D) -> Self
[src]
impl<D> Sub<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Sub<Output = D>,
[src]
D: Sub<Output = D>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: OrderedDecimal<D>) -> Self
[src]
impl Sub<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl Sub<OrderedDecimal<Decimal64>> for Decimal64
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: OrderedDecimal<Decimal64>) -> Self
[src]
impl<D> SubAssign<D> for OrderedDecimal<D> where
D: Sub<Output = D> + Copy,
[src]
D: Sub<Output = D> + Copy,
Subs inner directly.
fn sub_assign(&mut self, other: D)
[src]
impl<D> SubAssign<OrderedDecimal<D>> for OrderedDecimal<D> where
D: SubAssign,
[src]
D: SubAssign,
fn sub_assign(&mut self, other: Self)
[src]
impl<'a, D> Sum<&'a OrderedDecimal<D>> for OrderedDecimal<D> where
D: Sum<&'a D> + 'a,
[src]
D: Sum<&'a D> + 'a,
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = &'a OrderedDecimal<D>>,
[src]
I: Iterator<Item = &'a OrderedDecimal<D>>,
impl<D> Sum<OrderedDecimal<D>> for OrderedDecimal<D> where
D: Sum,
[src]
D: Sum,
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = OrderedDecimal<D>>,
[src]
I: Iterator<Item = OrderedDecimal<D>>,
Auto Trait Implementations
impl<D> RefUnwindSafe for OrderedDecimal<D> where
D: RefUnwindSafe,
D: RefUnwindSafe,
impl<D> Send for OrderedDecimal<D> where
D: Send,
D: Send,
impl<D> Sync for OrderedDecimal<D> where
D: Sync,
D: Sync,
impl<D> Unpin for OrderedDecimal<D> where
D: Unpin,
D: Unpin,
impl<D> UnwindSafe for OrderedDecimal<D> where
D: UnwindSafe,
D: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,