Trait Substitute

Source
pub trait Substitute<SubstExpr> {
    type Target;
    type Error;

    // Required method
    fn substitute(
        &self,
        expr: &SubstExpr,
        var: usize,
    ) -> Result<Self::Target, Self::Error>;
}
Expand description

A syntax node which admits a substitution operation.

Required Associated Types§

Source

type Target

The result of substituting an expression for a variable in this term. For most AST types this will be Self.

Source

type Error

The type of errors which may occur during substitution. In the simple case where SubstExpr == Target this should usually be set to std::convert::Infallible. However, in more complex cases you may want to implement Substitute<E> for other values of E (such as where you have mutually recursive expression types, each which may contain variables). In such cases substitute must handle the case where the variable index refers to a position in the wrong type of expression. N.B. currently the derive macro for Substitute will always use SubstError as the error type.

Required Methods§

Source

fn substitute( &self, expr: &SubstExpr, var: usize, ) -> Result<Self::Target, Self::Error>

Substitute expr into any variables in the expression matching the specified de Bruijn index.

Implementations on Foreign Types§

Source§

impl<T, U> Substitute<U> for Box<T>
where T: Substitute<U>,

Source§

type Target = Box<<T as Substitute<U>>::Target>

Source§

type Error = <T as Substitute<U>>::Error

Source§

fn substitute(&self, expr: &U, var: usize) -> Result<Self::Target, Self::Error>

Implementors§