MeetSemilattice

Trait MeetSemilattice 

Source
pub trait MeetSemilattice: Sized {
    // Required method
    fn meet(&self, other: &Self) -> Self;

    // Provided methods
    fn meet_assign(&mut self, other: &Self) { ... }
    fn leq_meet(&self, other: &Self) -> bool
       where Self: PartialEq { ... }
    fn meet_all<I>(it: I) -> Option<Self>
       where I: IntoIterator<Item = Self> { ... }
}
Expand description

A meet-semilattice: a type with an associative, commutative, idempotent binary operation that computes greatest lower bounds.

Laws (not enforced by type system):

  • Associative: a.meet(b).meet(c) == a.meet(b.meet(c))
  • Commutative: a.meet(b) == b.meet(a)
  • Idempotent: a.meet(a) == a

The meet operation computes the greatest lower bound (infimum) in the induced partial order: x ≤ y iff x.meet(y) == x.

§Example

use algebra_core::MeetSemilattice;
use std::collections::HashSet;

let a: HashSet<_> = [1, 2, 3].into_iter().collect();
let b: HashSet<_> = [2, 3, 4].into_iter().collect();

// meet = intersection
let c = a.meet(&b);
assert_eq!(c, [2, 3].into_iter().collect());

// Idempotent
assert_eq!(a.meet(&a), a);

Required Methods§

Source

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

The meet (greatest lower bound).

Provided Methods§

Source

fn meet_assign(&mut self, other: &Self)

In-place variant.

Source

fn leq_meet(&self, other: &Self) -> bool
where Self: PartialEq,

Derived partial order: x ≤ y iff x ∧ y = x.

Source

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

Meet a finite iterator of values. Returns None for empty iterators.

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 MeetSemilattice for bool

Source§

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

Source§

impl MeetSemilattice for ()

Source§

fn meet(&self, _other: &Self) -> Self

Source§

impl<A> MeetSemilattice for (A,)
where A: MeetSemilattice,

Source§

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

Source§

impl<A, B> MeetSemilattice for (A, B)

Source§

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

Source§

impl<A, B, C> MeetSemilattice for (A, B, C)

Source§

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

Source§

impl<A, B, C, D> MeetSemilattice for (A, B, C, D)

Source§

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

Source§

impl<L: MeetSemilattice + Clone> MeetSemilattice for Option<L>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§