Struct lattices::WithTop

source ·
pub struct WithTop<Inner>(/* private fields */);
Expand description

Adds a new “top” value to the nested lattice type.

Given an existing lattice, wrap it into a new lattice with a new top element. The new top element compares as less than all the values of the wrapped lattice. This can be used for giving a sensible default/bottom element to lattices that don’t necessarily have one.

The implementation wraps an Option, with None representing the top element.

Implementations§

source§

impl<Inner> WithTop<Inner>

source

pub fn new(val: Option<Inner>) -> Self

Create a new WithTop lattice instance from a value.

source

pub fn new_from(val: impl Into<Option<Inner>>) -> Self

Create a new WithTop lattice instance from a value using Into.

source

pub fn as_reveal_ref(&self) -> Option<&Inner>

Reveal the inner value as a shared reference.

source

pub fn as_reveal_mut(&mut self) -> Option<&mut Inner>

Reveal the inner value as an exclusive reference.

source

pub fn into_reveal(self) -> Option<Inner>

Gets the inner by value, consuming self.

Trait Implementations§

source§

impl<Inner> Atomize for WithTop<Inner>
where Inner: Atomize + LatticeFrom<<Inner as Atomize>::Atom>,

source§

type Atom = WithTop<<Inner as Atomize>::Atom>

The type of atoms for this lattice.
source§

type AtomIter = Box<dyn Iterator<Item = <WithTop<Inner> as Atomize>::Atom>>

The iter type iterating the antichain atoms.
source§

fn atomize(self) -> Self::AtomIter

Atomize self: convert into an iter of atoms. Read more
source§

impl<Inner: Clone> Clone for WithTop<Inner>

source§

fn clone(&self) -> WithTop<Inner>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Inner: Debug> Debug for WithTop<Inner>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Inner> DeepReveal for WithTop<Inner>
where Inner: DeepReveal,

source§

type Revealed = Option<<Inner as DeepReveal>::Revealed>

The underlying type when revealed.
source§

fn deep_reveal(self) -> Self::Revealed

Reveals the underlying lattice types recursively.
source§

impl<Inner> Default for WithTop<Inner>
where Inner: Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, Inner> Deserialize<'de> for WithTop<Inner>
where Inner: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Inner> IsBot for WithTop<Inner>
where Inner: IsBot,

source§

fn is_bot(&self) -> bool

Returns if self is lattice bottom (⊥). Read more
source§

impl<Inner> IsTop for WithTop<Inner>
where Inner: IsTop,

source§

fn is_top(&self) -> bool

Returns if self is lattice top (⊤). Read more
source§

impl<Inner, Other> LatticeFrom<WithTop<Other>> for WithTop<Inner>
where Inner: LatticeFrom<Other>,

source§

fn lattice_from(other: WithTop<Other>) -> Self

Convert from the Other lattice into Self.
source§

impl<Inner, Other> Merge<WithTop<Other>> for WithTop<Inner>
where Inner: Merge<Other> + LatticeFrom<Other>,

source§

fn merge(&mut self, other: WithTop<Other>) -> bool

Merge other into the self lattice. Read more
source§

fn merge_owned(this: Self, delta: Other) -> Self
where Self: Sized,

Merge this and delta together, returning the new value.
source§

impl<Inner, Other> PartialEq<WithTop<Other>> for WithTop<Inner>
where Inner: PartialEq<Other>,

source§

fn eq(&self, other: &WithTop<Other>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Inner, Other> PartialOrd<WithTop<Other>> for WithTop<Inner>
where Inner: PartialOrd<Other>,

source§

fn partial_cmp(&self, other: &WithTop<Other>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<Inner> Serialize for WithTop<Inner>
where Inner: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Inner: Copy> Copy for WithTop<Inner>

source§

impl<Inner: Eq> Eq for WithTop<Inner>

source§

impl<Inner, Other> LatticeOrd<WithTop<Other>> for WithTop<Inner>
where Self: PartialOrd<WithTop<Other>>,

Auto Trait Implementations§

§

impl<Inner> Freeze for WithTop<Inner>
where Inner: Freeze,

§

impl<Inner> RefUnwindSafe for WithTop<Inner>
where Inner: RefUnwindSafe,

§

impl<Inner> Send for WithTop<Inner>
where Inner: Send,

§

impl<Inner> Sync for WithTop<Inner>
where Inner: Sync,

§

impl<Inner> Unpin for WithTop<Inner>
where Inner: Unpin,

§

impl<Inner> UnwindSafe for WithTop<Inner>
where Inner: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<This, Other> NaiveLatticeOrd<Other> for This
where This: Clone + Merge<Other>, Other: Clone + Merge<This>,

source§

fn naive_cmp(&self, other: &Rhs) -> Option<Ordering>

Naive compare based on the Merge::merge method. This method can be very inefficient; use PartialOrd::partial_cmp instead. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Lattice for T