pub trait RowIterator: Debug {
// Required methods
fn next(&mut self) -> Option<&RowRef>;
fn peek(&mut self) -> Option<&RowRef>;
fn count(&self) -> usize;
fn box_clone(&self) -> Box<dyn RowIterator>;
// Provided method
fn map<T, F>(self, f: F) -> MappedRowIterator<Self, F> ⓘ
where Self: Sized,
F: FnMut(&RowRef) -> T { ... }
}Expand description
An iterator that can borrow from self and yield RowRefs.
This trait is a “lending iterator” for Rows, in other words, an iterator that borrows from
self (e.g. an underlying memory buffer) to return a RowRef. The std::iter::Iterator
trait does not currently support this pattern because there is no way to name the lifetime of
the borrow on its associated Item type. Generic Associated Types (GATs) would allow this but
so far no new trait has been introduced with this API.
There are a few open source crates that provide a trait:
Neither have an IntoLendingIterator trait that is useful for our interface, nor do they work
well with trait objects.
Required Methods§
Sourcefn count(&self) -> usize
fn count(&self) -> usize
The total number of Rows this iterator could ever yield.
Note: it does not return the number of rows remaining, in otherwords calling .next()
will not change the value returned from this method.
Sourcefn box_clone(&self) -> Box<dyn RowIterator>
fn box_clone(&self) -> Box<dyn RowIterator>
Returns a clone of self as a Box<dyn RowIterator>.
Provided Methods§
Sourcefn map<T, F>(self, f: F) -> MappedRowIterator<Self, F> ⓘ
fn map<T, F>(self, f: F) -> MappedRowIterator<Self, F> ⓘ
Maps the returned RowRefs from this RowIterator.