From 9b040da029114408d68defd35416ae4eb31ec99c Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Mon, 6 Apr 2020 13:01:39 -0700 Subject: [PATCH] =?UTF-8?q?Add=20`Rows::{mapped,and=5Fthen}`=20to=20get=20?= =?UTF-8?q?an=20Iterator=20out=20of=20a=20Rows=20i=E2=80=A6=20(#676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/row.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/row.rs b/src/row.rs index b6f3491..8983b3b 100644 --- a/src/row.rs +++ b/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(self, f: F) -> MappedRows<'stmt, F> + where + F: FnMut(&Row<'_>) -> Result, + { + 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(self, f: F) -> AndThenRows<'stmt, F> + where + F: FnMut(&Row<'_>) -> result::Result, + { + AndThenRows { rows: self, map: f } + } } impl<'stmt> Rows<'stmt> {