pub trait TracingEvaluator: Default {
type Data: From<f32> + Copy + Clone;
type Tape: Tape<Storage = Self::TapeStorage>;
type TapeStorage;
type Trace;
// Required method
fn eval(
&mut self,
tape: &Self::Tape,
vars: &[Self::Data],
) -> Result<(&'_ [Self::Data], Option<&'_ Self::Trace>), Error>;
// Provided method
fn new() -> Self { ... }
}
Expand description
Evaluator for single values which simultaneously captures an execution trace
The trace can later be used to simplify the
Function
using Function::simplify
.
Tracing evaluators may contain intermediate storage (e.g. an array of VM registers), and should be constructed on a per-thread basis.
Required Associated Types§
Sourcetype Tape: Tape<Storage = Self::TapeStorage>
type Tape: Tape<Storage = Self::TapeStorage>
Instruction tape used during evaluation
This may be a literal instruction tape (in the case of VM evaluation), or a metaphorical instruction tape (e.g. a JIT function).
Sourcetype TapeStorage
type TapeStorage
Associated type for tape storage
This is a workaround for plumbing purposes
Required Methods§
Sourcefn eval(
&mut self,
tape: &Self::Tape,
vars: &[Self::Data],
) -> Result<(&'_ [Self::Data], Option<&'_ Self::Trace>), Error>
fn eval( &mut self, tape: &Self::Tape, vars: &[Self::Data], ) -> Result<(&'_ [Self::Data], Option<&'_ Self::Trace>), Error>
Evaluates the given tape at a particular position
vars
should be a slice of values representing input arguments for each
of the tape’s variables; use Tape::vars
to map from
Var
to position in the list.
Returns an error if the var
slice is not of sufficient length.
Provided Methods§
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.