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
impl Level
Sourcepub fn mvar(id: LevelMVarId) -> Self
pub fn mvar(id: LevelMVarId) -> Self
Create a level metavariable.
Sourcepub fn is_not_zero(&self) -> bool
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.