pub struct TermDag { /* private fields */ }Expand description
A hashconsing arena for Terms.
Implementations§
Source§impl TermDag
impl TermDag
Sourcepub fn lookup(&self, node: &Term) -> TermId
pub fn lookup(&self, node: &Term) -> TermId
Convert the given term to its id.
Panics if the term does not already exist in this TermDag.
Sourcepub fn get(&self, id: TermId) -> &Term
pub fn get(&self, id: TermId) -> &Term
Convert the given id to the corresponding term.
Panics if the id is not valid.
Sourcepub fn app(&mut self, sym: String, children: Vec<Term>) -> Term
pub fn app(&mut self, sym: String, children: Vec<Term>) -> Term
Make and return a Term::App with the given head symbol and children,
and insert into the DAG if it is not already present.
Panics if any of the children are not already in the DAG.
Sourcepub fn lit(&mut self, lit: Literal) -> Term
pub fn lit(&mut self, lit: Literal) -> Term
Make and return a Term::Lit with the given literal, and insert into
the DAG if it is not already present.
Sourcepub fn var(&mut self, sym: String) -> Term
pub fn var(&mut self, sym: String) -> Term
Make and return a Term::Var with the given symbol, and insert into
the DAG if it is not already present.
Sourcepub fn expr_to_term(&mut self, expr: &GenericExpr<String, String>) -> Term
pub fn expr_to_term(&mut self, expr: &GenericExpr<String, String>) -> Term
Recursively converts the given expression to a term.
This involves inserting every subexpression into this DAG. Because TermDags are hashconsed, the resulting term is guaranteed to maximally share subterms.
Sourcepub fn term_to_expr(&self, term: &Term, span: Span) -> Expr
pub fn term_to_expr(&self, term: &Term, span: Span) -> Expr
Recursively converts the given term to an expression.
Panics if the term contains subterms that are not in the DAG.
Trait Implementations§
impl Eq for TermDag
impl StructuralPartialEq for TermDag
Auto Trait Implementations§
impl Freeze for TermDag
impl RefUnwindSafe for TermDag
impl Send for TermDag
impl Sync for TermDag
impl Unpin for TermDag
impl UnwindSafe for TermDag
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more