Skip to main content

OrdArithmetic

Trait OrdArithmetic 

Source
pub trait OrdArithmetic<T>: Arithmetic<T> {
    // Required method
    fn partial_cmp(&self, x: &T, y: &T) -> Option<Ordering>;
}
Expand description

Extends an Arithmetic with a comparison operation on values.

Required Methods§

Source

fn partial_cmp(&self, x: &T, y: &T) -> Option<Ordering>

Compares two values. Returns None if the numbers are not comparable, or the comparison result otherwise.

Trait Implementations§

Source§

impl<T> Arithmetic<T> for Box<dyn OrdArithmetic<T>>

Source§

fn add(&self, x: T, y: T) -> Result<T, ArithmeticError>

Adds two values. Read more
Source§

fn sub(&self, x: T, y: T) -> Result<T, ArithmeticError>

Subtracts two values. Read more
Source§

fn mul(&self, x: T, y: T) -> Result<T, ArithmeticError>

Multiplies two values. Read more
Source§

fn div(&self, x: T, y: T) -> Result<T, ArithmeticError>

Divides two values. Read more
Source§

fn pow(&self, x: T, y: T) -> Result<T, ArithmeticError>

Raises x to the power of y. Read more
Source§

fn neg(&self, x: T) -> Result<T, ArithmeticError>

Negates a value. Read more
Source§

fn eq(&self, x: &T, y: &T) -> bool

Checks if two values are equal. Note that equality can be a non-trivial operation; e.g., different numbers may be equal as per modular arithmetic.
Source§

impl<T> Debug for dyn OrdArithmetic<T> + '_

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> OrdArithmetic<T> for Box<dyn OrdArithmetic<T>>

Source§

fn partial_cmp(&self, x: &T, y: &T) -> Option<Ordering>

Compares two values. Returns None if the numbers are not comparable, or the comparison result otherwise.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> OrdArithmetic<T> for Box<dyn OrdArithmetic<T>>

Source§

fn partial_cmp(&self, x: &T, y: &T) -> Option<Ordering>

Implementors§

Source§

impl<T, A> OrdArithmetic<T> for FullArithmetic<T, A>
where A: Arithmetic<T>,

Source§

impl<T, Kind> OrdArithmetic<T> for CheckedArithmetic<Kind>
where Self: Arithmetic<T>, T: PartialOrd,

Source§

impl<T> OrdArithmetic<T> for StdArithmetic
where Self: Arithmetic<T>, T: PartialOrd,

Source§

impl<T> OrdArithmetic<T> for WrappingArithmetic
where Self: Arithmetic<T>, T: PartialOrd,