Skip to main content

Evaluator

Trait Evaluator 

Source
pub trait Evaluator {
    type Id;
    type Module;
    type Error;

    // Required methods
    fn is_empty(&self) -> bool;
    fn next(&mut self) -> Option<Self::Id>;
    fn eval(
        &mut self,
        id: Self::Id,
        imports: Imports<Self::Id>,
        module: Self::Module,
    ) -> Result<(), Self::Error>;
    fn finish(self) -> Option<Self::Module>;
}
Expand description

An evaluator.

An evaluator is the main mechanism with which Merge is utilized. The goal of the Evaluator is to Merge modules which may of may not import other modules.

Required Associated Types§

Source

type Id

Id of a module.

This can be anything that can uniquely identify a module. For example, a filesystem path.

Source

type Module

The type of the module.

Source

type Error

Evaluation error.

Required Methods§

Source

fn is_empty(&self) -> bool

Check whether the evaluator has evaluated any modules.

Source

fn next(&mut self) -> Option<Self::Id>

Get the next module in evaluation order.

Evaluation order is implementation-specific. An implementation might choose to evaluate modules in DFS, BFS or some other unspecified order. Returns None when there are no modules left to evaluate.

Source

fn eval( &mut self, id: Self::Id, imports: Imports<Self::Id>, module: Self::Module, ) -> Result<(), Self::Error>

Evaluate module identified by id that imports the modules specified by imports.

Source

fn finish(self) -> Option<Self::Module>

Destruct the evaluator and get the final value.

Returns None when no modules have been evaluated.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E> Evaluator for Acyclic<E>
where E: Evaluator, E::Id: Clone + Eq + Hash,

Available on crate feature std only.
Source§

impl<E> Evaluator for Metrics<E>
where E: Evaluator, E::Id: Clone + Eq + Hash,

Available on crate feature std only.
Source§

impl<I, M> Evaluator for Dfs<I, M>
where M: Merge,