pub struct ProgramRunner<S: Scalar, O> { /* private fields */ }Expand description
Builds a program the way an editor needs it built: incrementally, and only as far as asked.
It keeps the part after every step it has run. Running again after an edit reuses the part after the longest unchanged prefix of steps, so changing the last step replays one step, not the whole history. And a run can stop early — while a step in the middle is being edited, only the steps up to it need to run, however long the rest of the program is. Parts past the stop are kept, not discarded, so moving the stop back again costs nothing.
A run stops at the first step that fails: the steps after it would only fail too, for want of what it should have built.
Implementations§
Source§impl<S: Scalar, O: Operations> ProgramRunner<S, O>
impl<S: Scalar, O: Operations> ProgramRunner<S, O>
pub fn new() -> Self
Sourcepub fn run(&mut self, program: &Program<O>, stop: Option<usize>)
pub fn run(&mut self, program: &Program<O>, stop: Option<usize>)
Runs the first stop steps of program — all of them if None —
reusing whatever the previous runs built that still applies. See
ProgramRunner::part and ProgramRunner::results for the
outcome.
Sourcepub fn part_at(&self, n: usize) -> &Part<S>
pub fn part_at(&self, n: usize) -> &Part<S>
The part the first n steps of the last run built — or, where the
run stopped before, the part it built.
Sourcepub fn results(&self) -> &[StepResult]
pub fn results(&self) -> &[StepResult]
One result per step the last run covered.