Struct switcheroo::Generator[][src]

pub struct Generator<'a, Input: 'a, Output: 'a, Stack: Stack> { /* fields omitted */ }

Generator wraps a closure and allows suspending its execution more than once, returning a value each time.

If the closure finishes each other call to resume will yield None. If the closure panics the unwind will happen correctly across contexts.

Implementations

impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack> where
    Input: 'a,
    Output: 'a,
    Stack: Stack
[src]

pub fn new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack> where
    F: FnOnce(&Yielder<Input, Output>, Input) + 'a, 
[src]

Create a new generator from a stack and closure.

pub fn resume(&mut self, input: Input) -> Option<Output>[src]

Resume the generator yielding the next value.

pub fn started(&self) -> bool[src]

Returns true if the execution of the passed in closure started

pub fn finished(&self) -> bool[src]

Returns true if the generator finished running.

pub fn stack(self) -> Stack[src]

Consume the generator and extract the stack.

Trait Implementations

impl<'a, Input, Output, Stack> Drop for Generator<'a, Input, Output, Stack> where
    Input: 'a,
    Output: 'a,
    Stack: Stack
[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl<'a, Input, Output, Stack> Send for Generator<'a, Input, Output, Stack> where
    Input: 'a,
    Output: 'a,
    Stack: Stack
[src]

Auto Trait Implementations

impl<'a, Input, Output, Stack> RefUnwindSafe for Generator<'a, Input, Output, Stack> where
    Input: RefUnwindSafe,
    Output: RefUnwindSafe,
    Stack: RefUnwindSafe

impl<'a, Input, Output, Stack> !Sync for Generator<'a, Input, Output, Stack>

impl<'a, Input, Output, Stack> Unpin for Generator<'a, Input, Output, Stack> where
    Stack: Unpin

impl<'a, Input, Output, Stack> UnwindSafe for Generator<'a, Input, Output, Stack> where
    Input: RefUnwindSafe,
    Output: RefUnwindSafe,
    Stack: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.