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

Adapter that turns an iterator over Result<Word, ReadError> into a data source.

Wraps an iterator over Result<Word, ReadError> and implements ReadWords<Word, S, ReadError=ReadError> 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 InfallibleIteratorReadWords, and module-level documentation for a detailed usage example.

Implementations§

source§

impl<Iter: Iterator> FallibleIteratorReadWords<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 FallibleIteratorReadWords<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 FallibleIteratorReadWords<Iter>

source§

fn clone(&self) -> FallibleIteratorReadWords<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 FallibleIteratorReadWords<Iter>

source§

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

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

impl<Iter: Iterator> IntoIterator for FallibleIteratorReadWords<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, ReadError> ReadWords<Word, S> for FallibleIteratorReadWords<Iter>
where Iter: Iterator<Item = Result<Word, ReadError>>, S: Semantics, ReadError: Debug,

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

§

type ReadError = ReadError

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

fn read(&mut self) -> Result<Option<Word>, Self::ReadError>

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 FallibleIteratorReadWords<Iter>
where Iter: RefUnwindSafe,

§

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

§

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

§

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

§

impl<Iter> UnwindSafe for FallibleIteratorReadWords<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.