pub struct ExprHashcons { /* private fields */ }Expand description
Hash-consing table for Expr values.
Every unique expression (by structural equality) is assigned a stable
ExprId. Subsequent intern calls for the same expression return the
same ExprId and increment hit_count.
Implementations§
Source§impl ExprHashcons
impl ExprHashcons
Sourcepub fn intern(&mut self, expr: Expr) -> (ExprId, bool)
pub fn intern(&mut self, expr: Expr) -> (ExprId, bool)
Intern an expression.
Returns (id, was_new) where was_new is true if this expression
had never been interned before.
Sourcepub fn get(&self, id: ExprId) -> Option<&Expr>
pub fn get(&self, id: ExprId) -> Option<&Expr>
Look up an expression by ExprId.
Returns None if the ID is out of range (should not happen for
IDs produced by this table).
Sourcepub fn get_id(&self, expr: &Expr) -> Option<ExprId>
pub fn get_id(&self, expr: &Expr) -> Option<ExprId>
Find the ExprId for a structurally equal expression, if it exists.
Does not update hit/miss counters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExprHashcons
impl RefUnwindSafe for ExprHashcons
impl Send for ExprHashcons
impl Sync for ExprHashcons
impl Unpin for ExprHashcons
impl UnsafeUnpin for ExprHashcons
impl UnwindSafe for ExprHashcons
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