Skip to main content

Level

Struct Level 

Source
pub struct Level(/* private fields */);
Expand description

A universe level.

Levels form expressions over zero, successor, max, imax, parameters, and metavariables.

Structural sharing (wave5 Stage F): Level is a newtype over a reference-counted cell holding its outermost node (LevelKind), so cloning a whole level — e.g. every element of the Vec<Level> a Const carries — is an O(1) refcount bump, and sub-levels are shared by pointer. Match on the outermost node through Level::view.

Each level also stores a hash of its own structure, computed when it is built from the stored hashes of its sub-levels (see the kernel-private structural_hash module) — so an Expr that carries levels (a Sort, a Const) folds them into its own hash in O(1) each, without walking them.

Equality is exactly structural: the same allocation is equal, different stored hashes are different (equal levels always hash equal), and otherwise the nodes are compared. Hash writes the structure as it always did (not the stored hash), so a HashMap<Level, _> behaves as before.

Implementations§

Source§

impl Level

Source

pub fn view(&self) -> LevelView<'_>

Borrow this level’s outermost node for matching. O(1).

Source

pub fn zero() -> Self

Create Zero level.

Source

pub fn succ(l: Level) -> Self

Create a successor level.

Source

pub fn max(l1: Level, l2: Level) -> Self

Create a max level.

Source

pub fn imax(l1: Level, l2: Level) -> Self

Create an imax level.

Source

pub fn param(name: Name) -> Self

Create a parameter level.

Source

pub fn mvar(id: LevelMVarId) -> Self

Create a level metavariable.

Source

pub fn is_zero(&self) -> bool

Check if this is Zero.

Source

pub fn is_param(&self) -> bool

Check if this is a parameter.

Source

pub fn is_mvar(&self) -> bool

Check if this is a metavariable.

Source

pub fn is_succ(&self) -> bool

Check if this is a successor.

Source

pub fn is_max(&self) -> bool

Check if this is a max.

Source

pub fn is_imax(&self) -> bool

Check if this is an imax.

Source

pub fn is_not_zero(&self) -> bool

Check if this level is definitely not zero.

Returns true if we can statically determine this is >= 1.

Source

pub fn has_mvar(&self) -> bool

Check if this level contains any metavariables.

Source

pub fn has_param(&self) -> bool

Check if this level contains any parameters.

Source

pub fn depth(&self) -> usize

Get the depth (nesting) of this level expression.

Source

pub fn from_nat(n: u32) -> Self

Create a numeric level succ^n(zero).

Source

pub fn to_nat(&self) -> Option<u32>

Try to convert to a numeric level.

Returns Some(n) if this is succ^n(zero), None otherwise.

Trait Implementations§

Source§

impl Clone for Level

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Level

Source§

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

Formats as Level(<kind>) — the output of the derived implementation when Level wrapped the node kind directly. Code that hashes or orders terms by their Debug text depends on this spelling.

Source§

impl Display for Level

Source§

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

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

impl Eq for Level

Source§

impl Hash for Level

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Writes the structure, exactly as the derived implementation did when Level wrapped the node kind directly.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Level

Source§

fn eq(&self, other: &Level) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !Send for Level

§

impl !Sync for Level

§

impl Forget for Level

§

impl Freeze for Level

§

impl Move for Level

§

impl RefUnwindSafe for Level

§

impl Unpin for Level

§

impl UnsafeUnpin for Level

§

impl UnwindSafe for Level

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.