Trait PartialOrderBehaviour

Source
pub trait PartialOrderBehaviour {
    type Element;

    // Required method
    fn ge(&self, a: &Self::Element, b: &Self::Element) -> bool;

    // Provided methods
    fn pc(&self, a: &Self::Element, b: &Self::Element) -> Option<Ordering> { ... }
    fn le(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
    fn gt(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
    fn lt(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
    fn eq(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
    fn ip(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
    fn cp(&self, a: &Self::Element, b: &Self::Element) -> bool { ... }
}
Expand description

A trait to represent the behaviour of a partial order.

One needs to define the ‘greater than or equal to’ behaviour. But implementing this trait is not a guarantee that the type is a partial order; this requires care in the function you decide to implement.

Required Associated Types§

Source

type Element

A type representing the elements that a partial order compares.

Required Methods§

Source

fn ge(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a >= b in the partial order.

Provided Methods§

Source

fn pc(&self, a: &Self::Element, b: &Self::Element) -> Option<Ordering>

Returns a partial order comparison between two elements.

Source

fn le(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a <= b in the partial order.

Source

fn gt(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a > b in the partial order.

Source

fn lt(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a < b in the partial order.

Source

fn eq(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a == b in the partial order.

Source

fn ip(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a is incomparable with b in the partial order.

Source

fn cp(&self, a: &Self::Element, b: &Self::Element) -> bool

Returns whether a is comparable with b in the partial order.

Implementors§

Source§

impl<T, F> PartialOrderBehaviour for PartialOrder<T, F>
where F: Fn(&T, &T) -> bool,

Source§

impl<T, F> PartialOrderBehaviour for Poset<T, F>
where F: PartialOrderBehaviour<Element = T>,