pub enum WithBottom<T> {
Bottom,
Value(T),
}Expand description
Lifts any type T by adding a single Bottom element below all Value(t).
Bottomis absorbing forLattice::meet:meet(Bottom, x) = Bottom.Bottomis the identity forLattice::join:join(Bottom, x) = x.- Symmetric to
WithTop: compose asWithTop<WithBottom<T>>for a closed latticeBottom < Value(t) < Top.
Use case: represents “no progress yet” or “this data path has not started”. Makes the absence of a value explicit in the type system rather than relying on magic constants.
§Example
use antichain::{WithBottom, Lattice};
// Bottom absorbs meet.
let bottom: WithBottom<u64> = WithBottom::Bottom;
let val = WithBottom::Value(42u64);
assert_eq!(bottom.meet(&val), WithBottom::Bottom);
assert_eq!(val.meet(&bottom), WithBottom::Bottom);
// Bottom is the identity for join.
assert_eq!(bottom.join(&val), val);
assert_eq!(val.join(&bottom), val);Variants§
Trait Implementations§
Source§impl<T: Clone> Clone for WithBottom<T>
impl<T: Clone> Clone for WithBottom<T>
Source§fn clone(&self) -> WithBottom<T>
fn clone(&self) -> WithBottom<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for WithBottom<T>
impl<T: Debug> Debug for WithBottom<T>
impl<T: Eq> Eq for WithBottom<T>
Source§impl<T: PartialEq> PartialEq for WithBottom<T>
impl<T: PartialEq> PartialEq for WithBottom<T>
Source§fn eq(&self, other: &WithBottom<T>) -> bool
fn eq(&self, other: &WithBottom<T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<T: PartialOrd> PartialOrd for WithBottom<T>
impl<T: PartialOrd> PartialOrd for WithBottom<T>
impl<T: PartialEq> StructuralPartialEq for WithBottom<T>
Auto Trait Implementations§
impl<T> Freeze for WithBottom<T>where
T: Freeze,
impl<T> RefUnwindSafe for WithBottom<T>where
T: RefUnwindSafe,
impl<T> Send for WithBottom<T>where
T: Send,
impl<T> Sync for WithBottom<T>where
T: Sync,
impl<T> Unpin for WithBottom<T>where
T: Unpin,
impl<T> UnsafeUnpin for WithBottom<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for WithBottom<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more