Skip to main content

Crate llattice

Crate llattice 

Source
Expand description

llattice — a minimal lattice abstraction (join / meet).

A lattice is a partially-ordered set with two operations:

  • join — least upper bound / supremum (for sets: union; for numbers: max)
  • meet — greatest lower bound / infimum (for sets: intersection; for numbers: min)

This crate provides the Lattice trait plus built-in implementations for the common cases (integers, floats, bool, Option, HashSet, Vec) so that downstream crates can share one lattice vocabulary without re-deriving it. It has no dependencies.

§Examples

use llattice::Lattice;
use std::collections::HashSet;

// HashSet: join = union, meet = intersection
let a: HashSet<i32> = [1, 2].into_iter().collect();
let b: HashSet<i32> = [2, 3].into_iter().collect();
assert_eq!(a.join(&b), [1, 2, 3].into_iter().collect());
assert_eq!(a.meet(&b), [2].into_iter().collect());

// Numeric: join = max, meet = min
assert_eq!(5u32.join(&3), 5);
assert_eq!(5u32.meet(&3), 3);

Traits§

Lattice
A lattice provides join (least upper bound) and meet (greatest lower bound) operations.