pub enum GenericExpr<Head, Leaf> {
Var(Span, Leaf),
Call(Span, Head, Vec<GenericExpr<Head, Leaf>>),
Lit(Span, Literal),
}Variants§
Implementations§
Source§impl<Head: Clone + Display, Leaf: Hash + Clone + Display + Eq> GenericExpr<Head, Leaf>
impl<Head: Clone + Display, Leaf: Hash + Clone + Display + Eq> GenericExpr<Head, Leaf>
pub fn span(&self) -> Span
pub fn is_var(&self) -> bool
pub fn get_var(&self) -> Option<Leaf>
pub fn ast_size(&self) -> usize
pub fn walk(&self, pre: &mut impl FnMut(&Self), post: &mut impl FnMut(&Self))
pub fn fold<Out>(&self, f: &mut impl FnMut(&Self, Vec<Out>) -> Out) -> Out
Sourcepub fn visit_exprs(self, f: &mut impl FnMut(Self) -> Self) -> Self
pub fn visit_exprs(self, f: &mut impl FnMut(Self) -> Self) -> Self
Applys f to all sub-expressions (including self)
bottom-up, collecting the results.
Sourcepub fn subst<Head2, Leaf2>(
&self,
subst_leaf: &mut impl FnMut(&Span, &Leaf) -> GenericExpr<Head2, Leaf2>,
subst_head: &mut impl FnMut(&Head) -> Head2,
) -> GenericExpr<Head2, Leaf2>
pub fn subst<Head2, Leaf2>( &self, subst_leaf: &mut impl FnMut(&Span, &Leaf) -> GenericExpr<Head2, Leaf2>, subst_head: &mut impl FnMut(&Head) -> Head2, ) -> GenericExpr<Head2, Leaf2>
subst replaces occurrences of variables and head symbols in the expression.
pub fn subst_leaf<Leaf2>( &self, subst_leaf: &mut impl FnMut(&Span, &Leaf) -> GenericExpr<Head, Leaf2>, ) -> GenericExpr<Head, Leaf2>
pub fn vars(&self) -> impl Iterator<Item = Leaf> + '_
Trait Implementations§
Source§impl<Head: Clone, Leaf: Clone> Clone for GenericExpr<Head, Leaf>
impl<Head: Clone, Leaf: Clone> Clone for GenericExpr<Head, Leaf>
Source§fn clone(&self) -> GenericExpr<Head, Leaf>
fn clone(&self) -> GenericExpr<Head, Leaf>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Head, Leaf> Display for GenericExpr<Head, Leaf>
impl<Head, Leaf> Display for GenericExpr<Head, Leaf>
impl<Head: Eq, Leaf: Eq> Eq for GenericExpr<Head, Leaf>
impl<Head, Leaf> StructuralPartialEq for GenericExpr<Head, Leaf>
Auto Trait Implementations§
impl<Head, Leaf> Freeze for GenericExpr<Head, Leaf>
impl<Head, Leaf> RefUnwindSafe for GenericExpr<Head, Leaf>where
Leaf: RefUnwindSafe,
Head: RefUnwindSafe,
impl<Head, Leaf> Send for GenericExpr<Head, Leaf>
impl<Head, Leaf> Sync for GenericExpr<Head, Leaf>
impl<Head, Leaf> Unpin for GenericExpr<Head, Leaf>
impl<Head, Leaf> UnwindSafe for GenericExpr<Head, Leaf>where
Leaf: UnwindSafe,
Head: UnwindSafe,
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