pub struct InfallibleIteratorReadWords<Iter: Iterator> { /* private fields */ }
Expand description

Adapter that turns an iterator over Word into a data source.

Wraps an iterator over Word and implements ReadWords<Word, S, ReadError=Infallible> by pulling the iterator each time a client reads from it. If the iterator implements ExactSizeIterator then this wrapper also implements BoundedReadWords.

Implements ReadWord for arbitrary Semantics. This is legal since it doesn’t implement WriteWords, so the question how reads relate to writes is moot.

See also FallibleIteratorReadWords, and module-level documentation for a detailed usage example.

Implementations§

source§

impl<Iter: Iterator> InfallibleIteratorReadWords<Iter>

source

pub fn new<I, Word, ReadError>(iter: I) -> Self
where I: IntoIterator<IntoIter = Iter>, Iter: Iterator<Item = Result<Word, ReadError>>,

Creates the adapter for the provided iterator.

The provided iterator iter does not need to be fused (i.e., it may return Some after the first None even though a ReadWords wouldn’t be allowed to do the equivalent of that). The adapter calls iter.fuse() to ensure correct behavior.

You can get the (fused) iterator back by calling IntoIterator::into_iter.

Trait Implementations§

source§

impl<Iter, S, Word> BoundedReadWords<Word, S> for InfallibleIteratorReadWords<Iter>
where Self: ReadWords<Word, S>, Iter: ExactSizeIterator, S: Semantics,

source§

fn remaining(&self) -> usize

Returns the number of Words that are left for reading. Read more
source§

fn is_exhausted(&self) -> bool

Whether or not there is no data left to read. Read more
source§

impl<Iter: Clone + Iterator> Clone for InfallibleIteratorReadWords<Iter>

source§

fn clone(&self) -> InfallibleIteratorReadWords<Iter>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Iter: Debug + Iterator> Debug for InfallibleIteratorReadWords<Iter>

source§

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

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

impl<Iter: Iterator> IntoIterator for InfallibleIteratorReadWords<Iter>

§

type Item = <Iter as Iterator>::Item

The type of the elements being iterated over.
§

type IntoIter = Fuse<Iter>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<Iter, S, Word> ReadWords<Word, S> for InfallibleIteratorReadWords<Iter>
where Iter: Iterator<Item = Word>, S: Semantics,

Since InfallibleIteratorReadWords doesn’t implement WriteWords, it is allowed to implement ReadWords for all ReadWriteLogics

§

type ReadError = Infallible

The error type that can occur when reading from the data source, or Infallible. Read more
source§

fn read(&mut self) -> Result<Option<Word>, Infallible>

Reads a single Word from the data source and advances the state of the data source accordingly (i.e., so that the next read won’t read the same Word again). Read more
source§

fn maybe_exhausted(&self) -> bool

Returns true if the data source could be out of data. Read more

Auto Trait Implementations§

§

impl<Iter> RefUnwindSafe for InfallibleIteratorReadWords<Iter>
where Iter: RefUnwindSafe,

§

impl<Iter> Send for InfallibleIteratorReadWords<Iter>
where Iter: Send,

§

impl<Iter> Sync for InfallibleIteratorReadWords<Iter>
where Iter: Sync,

§

impl<Iter> Unpin for InfallibleIteratorReadWords<Iter>
where Iter: Unpin,

§

impl<Iter> UnwindSafe for InfallibleIteratorReadWords<Iter>
where Iter: 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.