BoundedJoinSemilattice

Trait BoundedJoinSemilattice 

Source
pub trait BoundedJoinSemilattice: JoinSemilattice {
    // Required method
    fn bottom() -> Self;

    // Provided method
    fn join_all_from_bottom<I>(it: I) -> Self
       where I: IntoIterator<Item = Self> { ... }
}
Expand description

A bounded join-semilattice: a join-semilattice with a bottom element that serves as the identity for join.

Laws (not enforced by type system):

  • Associative: a.join(b).join(c) == a.join(b.join(c))
  • Commutative: a.join(b) == b.join(a)
  • Idempotent: a.join(a) == a
  • Identity: bottom().join(a) == a == a.join(bottom())

The bottom element (⊥) is the least element in the partial order.

§Example

use algebra::BoundedJoinSemilattice;
use algebra::JoinSemilattice;
use algebra::Max;

let a = Max(10);

// bottom = minimum value
let bottom = Max::<i32>::bottom();

// Identity law
assert_eq!(bottom.join(&a), a);
assert_eq!(a.join(&bottom), a);

Required Methods§

Source

fn bottom() -> Self

The bottom element of the lattice (⊥).

This is the least element w.r.t. the induced partial order: for all x, bottom().join(x) == x.

Provided Methods§

Source

fn join_all_from_bottom<I>(it: I) -> Self
where I: IntoIterator<Item = Self>,

Join a finite iterator of values, starting from ⊥.

Never returns None: an empty iterator produces bottom().

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 BoundedJoinSemilattice for ()

Source§

fn bottom() -> Self

Source§

impl<L: JoinSemilattice + Clone> BoundedJoinSemilattice for Option<L>

Source§

fn bottom() -> Self

Source§

impl<T: Eq + Hash + Clone> BoundedJoinSemilattice for HashSet<T>

Source§

fn bottom() -> Self

Source§

impl<T: Ord + Clone> BoundedJoinSemilattice for BTreeSet<T>

Source§

fn bottom() -> Self

Implementors§