mirror of
https://github.com/isar/rusqlite.git
synced 2024-12-02 07:31:36 +08:00
Get rid of fallible iterator trait
This commit is contained in:
parent
73323b6b92
commit
f3c2b63836
20
src/lib.rs
20
src/lib.rs
@ -812,7 +812,6 @@ impl fmt::Debug for Connection {
|
|||||||
|
|
||||||
/// Batch iterator
|
/// Batch iterator
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use fallible_iterator::FallibleIterator;
|
|
||||||
/// use rusqlite::{Batch, Connection, Result, NO_PARAMS};
|
/// use rusqlite::{Batch, Connection, Result, NO_PARAMS};
|
||||||
///
|
///
|
||||||
/// fn main() -> Result<()> {
|
/// 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> {
|
pub fn new(conn: &'conn Connection, sql: &'sql str) -> Batch<'conn, 'sql> {
|
||||||
Batch { conn, sql, tail: 0 }
|
Batch { conn, sql, tail: 0 }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'conn> fallible_iterator::FallibleIterator for Batch<'conn, '_> {
|
/// Iterates on each batch statements.
|
||||||
type Error = Error;
|
///
|
||||||
type Item = Statement<'conn>;
|
/// Returns `Ok(None)` when batch is completed.
|
||||||
|
#[allow(clippy::should_implement_trait)] // fallible iterator
|
||||||
fn next(&mut self) -> Result<Option<Statement<'conn>>> {
|
pub fn next(&mut self) -> Result<Option<Statement<'conn>>> {
|
||||||
while self.tail < self.sql.len() {
|
while self.tail < self.sql.len() {
|
||||||
let sql = &self.sql[self.tail..];
|
let sql = &self.sql[self.tail..];
|
||||||
let next = self.conn.prepare(sql)?;
|
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<Statement<'conn>>;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Result<Statement<'conn>>> {
|
||||||
|
self.next().transpose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Flags for opening SQLite database connections.
|
/// Flags for opening SQLite database connections.
|
||||||
/// See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details.
|
/// See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details.
|
||||||
|
Loading…
Reference in New Issue
Block a user