mirror of
https://github.com/isar/rusqlite.git
synced 2025-02-21 15:28:14 +08:00
Add Rows::{mapped,and_then}
to get an Iterator out of a Rows i… (#676)
This commit is contained in:
parent
0394e114d0
commit
9b040da029
19
src/row.rs
19
src/row.rs
@ -41,6 +41,25 @@ impl<'stmt> Rows<'stmt> {
|
||||
{
|
||||
Map { rows: self, f }
|
||||
}
|
||||
|
||||
/// Map over this `Rows`, converting it to a [`MappedRows`], which
|
||||
/// implements `Iterator`.
|
||||
pub fn mapped<F, B>(self, f: F) -> MappedRows<'stmt, F>
|
||||
where
|
||||
F: FnMut(&Row<'_>) -> Result<B>,
|
||||
{
|
||||
MappedRows { rows: self, map: f }
|
||||
}
|
||||
|
||||
/// Map over this `Rows` with a fallible function, converting it to a
|
||||
/// [`AndThenRows`], which implements `Iterator` (instead of
|
||||
/// `FallibleStreamingIterator`).
|
||||
pub fn and_then<F, T, E>(self, f: F) -> AndThenRows<'stmt, F>
|
||||
where
|
||||
F: FnMut(&Row<'_>) -> result::Result<T, E>,
|
||||
{
|
||||
AndThenRows { rows: self, map: f }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'stmt> Rows<'stmt> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user