Enum fixed_decimal::RoundingMode
source · #[non_exhaustive]pub enum RoundingMode {
Ceil,
Expand,
Floor,
Trunc,
HalfCeil,
HalfExpand,
HalfFloor,
HalfTrunc,
HalfEven,
}
Expand description
Mode used in a rounding operation.
§Comparative table of rounding modes
Value | Ceil | Expand | Floor | Trunc | HalfCeil | HalfExpand | HalfFloor | HalfTrunc | HalfEven |
---|---|---|---|---|---|---|---|---|---|
+1.8 | +2 | +2 | +1 | +1 | +2 | +2 | +2 | +2 | +2 |
+1.5 | “ | “ | “ | “ | “ | “ | +1 | +1 | “ |
+1.2 | “ | “ | “ | “ | +1 | +1 | “ | “ | +1 |
+0.8 | +1 | +1 | 0 | 0 | “ | “ | “ | “ | “ |
+0.5 | “ | “ | “ | “ | “ | “ | 0 | 0 | 0 |
+0.2 | “ | “ | “ | “ | 0 | 0 | “ | “ | “ |
-0.2 | 0 | -1 | -1 | “ | “ | “ | “ | “ | “ |
-0.5 | “ | “ | “ | “ | “ | -1 | -1 | “ | “ |
-0.8 | “ | “ | “ | “ | -1 | “ | “ | -1 | -1 |
-1.2 | -1 | -2 | -2 | -1 | “ | “ | “ | “ | “ |
-1.5 | “ | “ | “ | “ | “ | -2 | -2 | “ | -2 |
-1.8 | “ | “ | “ | “ | -2 | “ | “ | -2 | “ |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Ceil
Round up, or towards positive infinity.
Expand
Round away from zero, or towards infinity.
Floor
Round down, or towards negative infinity.
Trunc
Round towards zero, or away from infinity.
HalfCeil
Round to the nearest integer, resolving ties by rounding up.
HalfExpand
Round to the nearest integer, resolving ties by rounding away from zero.
HalfFloor
Round to the nearest integer, resolving ties by rounding down.
HalfTrunc
Round to the nearest integer, resolving ties by rounding towards zero.
HalfEven
Round to the nearest integer, resolving ties by rounding towards the nearest even integer.
Trait Implementations§
source§impl Clone for RoundingMode
impl Clone for RoundingMode
source§fn clone(&self) -> RoundingMode
fn clone(&self) -> RoundingMode
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RoundingMode
impl Debug for RoundingMode
source§impl Ord for RoundingMode
impl Ord for RoundingMode
source§fn cmp(&self, other: &RoundingMode) -> Ordering
fn cmp(&self, other: &RoundingMode) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for RoundingMode
impl PartialEq for RoundingMode
source§impl PartialOrd for RoundingMode
impl PartialOrd for RoundingMode
impl Copy for RoundingMode
impl Eq for RoundingMode
impl StructuralPartialEq for RoundingMode
Auto Trait Implementations§
impl Freeze for RoundingMode
impl RefUnwindSafe for RoundingMode
impl Send for RoundingMode
impl Sync for RoundingMode
impl Unpin for RoundingMode
impl UnwindSafe for RoundingMode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more