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§
Provided Methods§
Sourcefn meet_assign(&mut self, other: &Self)
fn meet_assign(&mut self, other: &Self)
In-place variant.
Sourcefn leq_meet(&self, other: &Self) -> boolwhere
Self: PartialEq,
fn leq_meet(&self, other: &Self) -> boolwhere
Self: PartialEq,
Derived partial order: x ≤ y iff x ∧ y = x.
Sourcefn meet_all<I>(it: I) -> Option<Self>where
I: IntoIterator<Item = Self>,
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.