pub trait FallibleIteratorMut {
type Item;
type Error;
// Required method
fn next(&mut self) -> Result<Option<&mut Self::Item>, Self::Error>;
// Provided methods
fn size_hint(&self) -> (usize, Option<usize>) { ... }
fn map<F, B>(&mut self, f: F) -> Map<'_, Self, F>
where Self: Sized,
F: FnMut(&mut Self::Item) -> Result<B, Self::Error> { ... }
}Expand description
Provides a FallibleIterator over mutable references.
Ordinarily a FallibleIterator iterates over owned items, which makes this trait
incompatible with it. The map method allows converting this trait into a
FallibleIterator, and it’s also possible to use with a while let loop:
use sqlite3_ext::FallibleIteratorMut;
fn dump<I: FallibleIteratorMut>(mut it: I) -> Result<(), I::Error>
where
I::Item: std::fmt::Debug,
{
while let Some(x) = it.next()? {
println!("{:?}", x);
}
Ok(())
}