Trait Evaluator

Source
pub trait Evaluator<Idx, B, U, T> {
    type Value;
    type Error;

    // Required methods
    fn evaluate_binary_operator(
        &mut self,
        span: Span<Idx>,
        operator: B,
        lhs: Self::Value,
        rhs: Self::Value,
    ) -> Result<Self::Value, Self::Error>;
    fn evaluate_unary_operator(
        &mut self,
        span: Span<Idx>,
        operator: U,
        argument: Self::Value,
    ) -> Result<Self::Value, Self::Error>;
    fn evaluate_term(
        &mut self,
        span: Span<Idx>,
        term: T,
    ) -> Result<Self::Value, Self::Error>;

    // Provided method
    fn evaluate<I>(&mut self, input: I) -> Result<Self::Value, Self::Error>
       where I: IntoIterator<Item = Expression<Idx, B, U, T>> { ... }
}

Required Associated Types§

Required Methods§

Source

fn evaluate_binary_operator( &mut self, span: Span<Idx>, operator: B, lhs: Self::Value, rhs: Self::Value, ) -> Result<Self::Value, Self::Error>

Source

fn evaluate_unary_operator( &mut self, span: Span<Idx>, operator: U, argument: Self::Value, ) -> Result<Self::Value, Self::Error>

Source

fn evaluate_term( &mut self, span: Span<Idx>, term: T, ) -> Result<Self::Value, Self::Error>

Provided Methods§

Source

fn evaluate<I>(&mut self, input: I) -> Result<Self::Value, Self::Error>
where I: IntoIterator<Item = Expression<Idx, B, U, T>>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Idx, B, U, T, E> Evaluator<Idx, B, U, T> for PureEvaluator
where B: FnOnce(T, T) -> Result<T, E>, U: FnOnce(T) -> Result<T, E>,

Source§

type Value = T

Source§

type Error = E