Skip to main content

NumericOps

Trait NumericOps 

Source
pub trait NumericOps:
    Copy
    + Clone
    + PartialOrd
    + PartialEq {
    // Required methods
    fn checked_add(&self, other: Self) -> Option<Self>;
    fn checked_sub(&self, other: Self) -> Option<Self>;
    fn checked_mul(&self, other: Self) -> Option<Self>;
    fn checked_div(&self, other: Self) -> Option<Self>;
    fn checked_rem(&self, other: Self) -> Option<Self>;
    fn saturating_add(&self, other: Self) -> Self;
    fn saturating_sub(&self, other: Self) -> Self;
    fn saturating_mul(&self, other: Self) -> Self;
    fn round_2dp(self) -> Self;
    fn zero() -> Self;
    fn is_sign_positive(&self) -> bool;
    fn is_sign_negative(&self) -> bool;
}
Expand description

Helper trait for numeric operations that work across both Decimal and f64

Required Methods§

Source

fn checked_add(&self, other: Self) -> Option<Self>

Source

fn checked_sub(&self, other: Self) -> Option<Self>

Source

fn checked_mul(&self, other: Self) -> Option<Self>

Source

fn checked_div(&self, other: Self) -> Option<Self>

Source

fn checked_rem(&self, other: Self) -> Option<Self>

Source

fn saturating_add(&self, other: Self) -> Self

Source

fn saturating_sub(&self, other: Self) -> Self

Source

fn saturating_mul(&self, other: Self) -> Self

Source

fn round_2dp(self) -> Self

Source

fn zero() -> Self

Source

fn is_sign_positive(&self) -> bool

Source

fn is_sign_negative(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl NumericOps for f64

Source§

fn checked_add(&self, other: Self) -> Option<Self>

Source§

fn checked_sub(&self, other: Self) -> Option<Self>

Source§

fn checked_mul(&self, other: Self) -> Option<Self>

Source§

fn checked_div(&self, other: Self) -> Option<Self>

Source§

fn checked_rem(&self, other: Self) -> Option<Self>

Source§

fn saturating_add(&self, other: Self) -> Self

Source§

fn saturating_sub(&self, other: Self) -> Self

Source§

fn saturating_mul(&self, other: Self) -> Self

Source§

fn round_2dp(self) -> Self

Source§

fn zero() -> Self

Source§

fn is_sign_positive(&self) -> bool

Source§

fn is_sign_negative(&self) -> bool

Implementors§