From f3c2b638360226246b34c8289d05eccafe7b4a1b Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 31 Oct 2020 10:47:44 +0100 Subject: [PATCH] Get rid of fallible iterator trait --- src/lib.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a7c7680..ddf318f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -812,7 +812,6 @@ impl fmt::Debug for Connection { /// Batch iterator /// ```rust -/// use fallible_iterator::FallibleIterator; /// use rusqlite::{Batch, Connection, Result, NO_PARAMS}; /// /// fn main() -> Result<()> { @@ -840,13 +839,12 @@ impl<'conn, 'sql> Batch<'conn, 'sql> { pub fn new(conn: &'conn Connection, sql: &'sql str) -> Batch<'conn, 'sql> { Batch { conn, sql, tail: 0 } } -} -impl<'conn> fallible_iterator::FallibleIterator for Batch<'conn, '_> { - type Error = Error; - type Item = Statement<'conn>; - - fn next(&mut self) -> Result>> { + /// Iterates on each batch statements. + /// + /// Returns `Ok(None)` when batch is completed. + #[allow(clippy::should_implement_trait)] // fallible iterator + pub fn next(&mut self) -> Result>> { while self.tail < self.sql.len() { let sql = &self.sql[self.tail..]; let next = self.conn.prepare(sql)?; @@ -865,6 +863,14 @@ impl<'conn> fallible_iterator::FallibleIterator for Batch<'conn, '_> { } } +impl<'conn> Iterator for Batch<'conn, '_> { + type Item = Result>; + + fn next(&mut self) -> Option>> { + self.next().transpose() + } +} + bitflags::bitflags! { /// Flags for opening SQLite database connections. /// See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details.