OrderedRing

Trait OrderedRing 

Source
pub trait OrderedRing: RingBase {
    // Required method
    fn cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering;

    // Provided methods
    fn abs_cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering { ... }
    fn is_leq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool { ... }
    fn is_geq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool { ... }
    fn is_lt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool { ... }
    fn is_gt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool { ... }
    fn is_neg(&self, value: &Self::Element) -> bool { ... }
    fn is_pos(&self, value: &Self::Element) -> bool { ... }
    fn abs(&self, value: Self::Element) -> Self::Element { ... }
    fn max<'a>(
        &self,
        fst: &'a Self::Element,
        snd: &'a Self::Element,
    ) -> &'a Self::Element { ... }
}
Expand description

Trait for rings that have a total ordering on their elements. The ordering must be compatible with addition and multiplication in the usual sense.

In particular, this should only be implemented for rings that are subrings of the real numbers.

Required Methods§

Source

fn cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering

Returns whether lhs is Ordering::Less, Ordering::Equal or Ordering::Greater than rhs.

Provided Methods§

Source

fn abs_cmp(&self, lhs: &Self::Element, rhs: &Self::Element) -> Ordering

Returns whether abs(lhs) is Ordering::Less, Ordering::Equal or Ordering::Greater than abs(rhs).

Source

fn is_leq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs <= rhs.

Source

fn is_geq(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs >= rhs.

Source

fn is_lt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs < rhs.

Source

fn is_gt(&self, lhs: &Self::Element, rhs: &Self::Element) -> bool

Returns whether lhs > rhs.

Source

fn is_neg(&self, value: &Self::Element) -> bool

Returns whether value < 0.

Source

fn is_pos(&self, value: &Self::Element) -> bool

Returns whether value > 0.

Source

fn abs(&self, value: Self::Element) -> Self::Element

Returns the absolute value of value, i.e. value if value >= 0 and -value otherwise.

Source

fn max<'a>( &self, fst: &'a Self::Element, snd: &'a Self::Element, ) -> &'a Self::Element

Returns the larger one of fst and snd.

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.

Implementors§