Struct BoxedGenerator

Source
pub struct BoxedGenerator<T> { /* private fields */ }
Available on crate feature std only.
Expand description

Box a generator, type-erasing the actual generator type. See .boxed() for details.

Trait Implementations§

Source§

impl<T> Generator for BoxedGenerator<T>

Source§

type Output = T

Data-type generated by the generator.
Source§

fn run( &mut self, output: impl FnMut(Self::Output) -> ValueResult, ) -> GeneratorResult

Run the generator, emitting values to the output closure. Read more
Source§

fn try_advance(&mut self, n: NonZeroUsize) -> (usize, GeneratorResult)

Try to advance the generator n values, ignoring them. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BoxedGenerator<T>

§

impl<T> !RefUnwindSafe for BoxedGenerator<T>

§

impl<T> !Send for BoxedGenerator<T>

§

impl<T> !Sync for BoxedGenerator<T>

§

impl<T> Unpin for BoxedGenerator<T>

§

impl<T> !UnwindSafe for BoxedGenerator<T>

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> DynGenerator for T
where T: Generator,

Source§

type Output = <T as Generator>::Output

The output type of this generator.
Source§

fn run_dyn( &mut self, output: &mut dyn FnMut(<T as DynGenerator>::Output) -> ValueResult, ) -> GeneratorResult

Run the generator using a &mut dyn FnMut instead of impl FnMut. This
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GeneratorExt for T
where T: Generator,

Source§

fn all<F>(&mut self, predicate: F) -> bool
where F: FnMut(Self::Output) -> bool,

Tests if every value from the generator matches a predicate. Read more
Source§

fn any<F>(&mut self, predicate: F) -> bool
where F: FnMut(Self::Output) -> bool,

Tests if any value matches a predicate. Read more
Source§

fn next(&mut self) -> Result<Self::Output, GeneratorResult>

Retrieve the next value from the generator Read more
Source§

fn last(self) -> Option<Self::Output>
where Self: Sized,

Exhausts the generator, returning the last element. Read more
Source§

fn cloned<'a, T>(self) -> Cloned<Self>
where Self: Generator<Output = &'a T> + Sized, T: 'a + Clone,

Creates a generator that clones all of its elements. Read more
Source§

fn copied<'a, T>(self) -> Copied<Self>
where T: 'a + Copy, Self: Generator<Output = &'a T> + Sized,

Creates a generator that copies all of its elements. Read more
Source§

fn chain<Gen>(self, other: Gen) -> Chain<Self, Gen>
where Self: Sized, Gen: Generator<Output = Self::Output>,

Creates a generator by chaining two generators, running them one after the other. Read more
Source§

fn filter<Pred>(self, predicate: Pred) -> Filter<Self, Pred>
where Self: Sized, Pred: FnMut(&Self::Output) -> bool,

Create a filtered generator. Only values for which the predicate returns true will be passed on. Read more
Source§

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Option<B>,

Creates a generator that both filters and maps. Read more
Source§

fn map<Trans, Out>(self, transform_fn: Trans) -> Map<Self, Trans>
where Self: Sized, Trans: FnMut(Self::Output) -> Out,

Takes a closure and creates a generator which calls the closure on each value. Read more
Source§

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

Skips over n values, consuming and ignoring them. Read more
Source§

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Output) -> bool,

Creates a generator that skips values based on a predicate. Read more
Source§

fn take(self, n: usize) -> Take<Self>
where Self: Sized,

Takes n values and then completes the generator. Read more
Source§

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Output) -> bool,

Creates a generator that pushes values based on a predicate. Read more
Source§

fn flat_map<U, F>(self, f: F) -> Flatten<Map<Self, F>>
where Self: Sized, U: IntoGenerator, F: FnMut(Self::Output) -> U,

Creates a generator that works like map, but flattens nested structure. Read more
Source§

fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Output: IntoGenerator,

Creates a generator that flattens nested structure. Read more
Source§

fn for_each<Func>(&mut self, func: Func) -> GeneratorResult
where Self: Sized, Func: FnMut(Self::Output),

Run a generator to completion, or until it is stopped, and call a closure for each value produced by the generator. Read more
Source§

fn try_for_each<F, E>(&mut self, f: F) -> Result<(), E>
where Self: Sized, F: FnMut(Self::Output) -> Result<(), E>,

A generator method that applies a fallible function to each item produced, stopping at the first error and returning that error. Read more
Source§

fn zip<Right>(self, right: Right) -> Zip<Self, Right>
where Self: Sized, Right: Generator,

Zips the output of two generators into a single generator of pairs. Read more
Source§

fn dedup(self) -> Dedup<Self>
where Self: Sized, Self::Output: PartialEq,

Create a de-duplicating generator, removing consecutive duplicate values. Read more
Source§

fn iter(self) -> IteratorAdaptor<Self>
where Self: Sized,

Create an iterator from a generator. Read more
Source§

fn step_by(self, step_size: usize) -> StepBy<Self>
where Self: Sized,

Create a generator that starts at the same point but steps by the given amount. Read more
Source§

fn boxed(self) -> BoxedGenerator<Self::Output>
where Self: Sized + 'static,

Available on crate feature std only.
Box a generator, making it possible to use as return value in for instance traits. Read more
Source§

fn sum<S>(self) -> S
where Self: Sized, S: Sum<Self::Output>,

Sums the values of a generator. Takes each value and adds them together and returns the result. Read more
Source§

fn product<P>(self) -> P
where Self: Sized, P: Product<Self::Output>,

Multiplies the values of a generator. Takes each value and adds them together and returns the result. Read more
Source§

fn min(self) -> Option<Self::Output>
where Self: Sized, Self::Output: Ord,

Returns the minimum value of a generator. Read more
Source§

fn min_by<F>(self, compare: F) -> Option<Self::Output>
where Self: Sized, F: FnMut(&Self::Output, &Self::Output) -> Ordering,

Returns the value that gives the minimum value when compared with the specified comparison function. Read more
Source§

fn try_min_by<F>( &mut self, partial: Option<Self::Output>, compare: F, ) -> TryReduction<Option<Self::Output>>
where Self: Sized, F: FnMut(&Self::Output, &Self::Output) -> Ordering,

Returns the value that gives the minimum value when compared with the specified comparison function. Read more
Source§

fn min_by_key<F, B>(self, f: F) -> Option<Self::Output>
where Self: Sized, F: FnMut(&Self::Output) -> B, B: Ord,

Returns the value that gives the minimum value from the specified function. Read more
Source§

fn max(self) -> Option<Self::Output>
where Self: Sized, Self::Output: Ord,

Returns the maximum value of a generator. Read more
Source§

fn max_by<F>(self, compare: F) -> Option<Self::Output>
where Self: Sized, F: FnMut(&Self::Output, &Self::Output) -> Ordering,

Returns the value that gives the maximum value when compared with the specified comparison function. Read more
Source§

fn try_max_by<F>( &mut self, partial: Option<Self::Output>, compare: F, ) -> TryReduction<Option<Self::Output>>
where Self: Sized, F: FnMut(&Self::Output, &Self::Output) -> Ordering,

Returns the value that gives the maximum value when compared with the specified comparison function. Read more
Source§

fn max_by_key<F, B>(self, f: F) -> Option<Self::Output>
where Self: Sized, F: FnMut(&Self::Output) -> B, B: Ord,

Returns the value that gives the maximum value from the specified function. Read more
Source§

fn fold<B, F>(self, init: B, folder: F) -> B
where Self: Sized, F: FnMut(B, Self::Output) -> B,

Folds every element into an accumulator by applying an operation, returning the final result. Read more
Source§

fn try_fold<B, F, E>( &mut self, init: B, folder: F, ) -> Result<TryReduction<B>, E>
where Self: Sized, F: FnMut(B, Self::Output) -> Result<B, E>,

Apply a function as long as the return value is successful, producing a single final value. Read more
Source§

fn reduce<F>(self, reducer: F) -> Option<Self::Output>
where Self: Sized, F: FnMut(Self::Output, Self::Output) -> Self::Output,

Reduces the elements to a single one by repeatedly applying a reducing operation. Read more
Source§

fn try_reduce<F>( &mut self, prev_reduction: Option<Self::Output>, reducer: F, ) -> TryReduction<Option<Self::Output>>
where Self: Sized, F: FnMut(Self::Output, Self::Output) -> Self::Output,

Reduces the values to a single value by repeatedly applying a reducing operation. Read more
Source§

fn collect<B>(self) -> B
where Self: Sized, B: FromGenerator<Self::Output>,

Transforms a generator into a collection. Read more
Source§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Creates a generator which gives the current generation count as well as the value. Read more
Source§

fn inspect<F>(self, inspector: F) -> Inspect<Self, F>
where Self: Sized, F: FnMut(&Self::Output),

Does something with each value from the generator, passing the value on. Read more
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<G> IntoGenerator for G
where G: Generator,

Source§

type Output = <G as Generator>::Output

Data-type generated by the generator.
Source§

type IntoGen = G

Which kind of generator are we turning this into?
Source§

fn into_gen(self) -> <G as IntoGenerator>::IntoGen

Creates a generator from a value. Read more
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.