Skip to main content

Schedule

Struct Schedule 

Source
pub struct Schedule<C> { /* private fields */ }
Expand description

An ordered sequence of passes, indexed by round.

Round r of an Engine run applies the pass at index r of the schedule to every node that is ready for it, so a schedule doubles as the fixed pass order of a run. Nodes created (or failed) in round r are processed by round r + 1, which uses the next pass in the schedule.

§Examples

use increparse::{Outcome, Pass, Schedule, Span};

struct WholeFile;
struct Statements;

struct NoopCtx;

impl Pass for WholeFile {
    type Ctx = ();
    fn parse(&self, _source: &str, _span: Span, _ctx: &()) -> Outcome<()> {
        Outcome::Done
    }
}

impl Pass for Statements {
    type Ctx = ();
    fn parse(&self, _source: &str, _span: Span, _ctx: &()) -> Outcome<()> {
        Outcome::Done
    }
}

let mut schedule = Schedule::new();
schedule.push(WholeFile);
schedule.push(Statements);
assert_eq!(schedule.len(), 2);

Implementations§

Source§

impl<C> Schedule<C>

Source

pub fn new() -> Schedule<C>

Creates an empty schedule.

Source

pub fn push<P>(&mut self, pass: P)
where P: Pass<Ctx = C> + Send + Sync + 'static,

Appends pass to the schedule; its round index is the previous length.

Source

pub fn push_boxed(&mut self, pass: Box<dyn Pass<Ctx = C> + Send + Sync>)

Appends an already-boxed pass.

Source

pub fn len(&self) -> usize

Number of passes in the schedule; also the maximum number of rounds.

Source

pub fn is_empty(&self) -> bool

Returns true if the schedule has no passes.

Source

pub fn pass_name(&self, round: usize) -> Option<&'static str>

Returns the name of the pass scheduled for round, if any.

Trait Implementations§

Source§

impl<C> Debug for Schedule<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<C> Default for Schedule<C>

Source§

fn default() -> Schedule<C>

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

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for Schedule<C>

§

impl<C> !UnwindSafe for Schedule<C>

§

impl<C> Freeze for Schedule<C>
where Vec<Box<dyn Pass<Ctx = C> + Send + Sync>>: Freeze,

§

impl<C> Send for Schedule<C>
where Vec<Box<dyn Pass<Ctx = C> + Send + Sync>>: Send,

§

impl<C> Sync for Schedule<C>
where Vec<Box<dyn Pass<Ctx = C> + Send + Sync>>: Sync,

§

impl<C> Unpin for Schedule<C>
where Vec<Box<dyn Pass<Ctx = C> + Send + Sync>>: Unpin,

§

impl<C> UnsafeUnpin for Schedule<C>
where Vec<Box<dyn Pass<Ctx = C> + Send + Sync>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.