Skip to main content

ProgramRunner

Struct ProgramRunner 

Source
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>

Source

pub fn new() -> Self

Source

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.

Source

pub fn part(&self) -> &Part<S>

The part the last run built.

Source

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.

Source

pub fn results(&self) -> &[StepResult]

One result per step the last run covered.

Trait Implementations§

Source§

impl<S: Scalar, O: Operations> Default for ProgramRunner<S, O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, O> Freeze for ProgramRunner<S, O>

§

impl<S, O> RefUnwindSafe for ProgramRunner<S, O>

§

impl<S, O> Send for ProgramRunner<S, O>
where O: Send,

§

impl<S, O> Sync for ProgramRunner<S, O>
where O: Sync,

§

impl<S, O> Unpin for ProgramRunner<S, O>
where O: Unpin, S: Unpin,

§

impl<S, O> UnsafeUnpin for ProgramRunner<S, O>

§

impl<S, O> UnwindSafe for ProgramRunner<S, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.