IterInput

Struct IterInput 

Source
pub struct IterInput<I, C>
where I: Iterator,
{ /* private fields */ }
Expand description

An input adapter that wraps any iterator and provides a TryNextWithContext interface, automatically fusing the iterator so it never yields items after returning None once.

§Type Parameters

  • I: The underlying iterator type. It can be any Iterator.
  • C: The context type, which is passed by mutable reference to each try_next_with_context call.

Implementations§

Source§

impl<I, C> IterInput<I, C>
where I: Iterator,

Source

pub fn from(iter: I) -> Self

Creates a new IterInput from any iterator.

The iterator is automatically fused internally, so that once it returns None, all further next() calls will also return None.

Trait Implementations§

Source§

impl<I, C> TryNextWithContext for IterInput<I, C>
where I: Iterator,

Source§

type Item = <I as Iterator>::Item

The type of items yielded by this source.
Source§

type Error = Infallible

The error type that may be returned when producing the next item fails.
Source§

type Context = C

The type of context passed to each call to try_next.
Source§

fn try_next_with_context( &mut self, _context: &mut Self::Context, ) -> Result<Option<Self::Item>, Self::Error>

Attempts to produce the next item, using the provided mutable context. Read more
Source§

fn try_collect_with_context( &mut self, context: &mut Self::Context, ) -> Result<Vec<Self::Item>, Self::Error>

Collects all remaining items into a Vec, using the given context. Read more

Auto Trait Implementations§

§

impl<I, C> Freeze for IterInput<I, C>
where I: Freeze,

§

impl<I, C> RefUnwindSafe for IterInput<I, C>
where I: RefUnwindSafe,

§

impl<I, C> Send for IterInput<I, C>
where I: Send,

§

impl<I, C> Sync for IterInput<I, C>
where I: Sync,

§

impl<I, C> Unpin for IterInput<I, C>
where I: Unpin,

§

impl<I, C> UnwindSafe for IterInput<I, C>
where I: UnwindSafe,

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.