mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Factorize code
This commit is contained in:
parent
e8967388e6
commit
8bb624cccc
12
src/lib.rs
12
src/lib.rs
@ -614,14 +614,7 @@ impl<'conn> SqliteStatement<'conn> {
|
|||||||
self.reset_if_needed();
|
self.reset_if_needed();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(params.len() as c_int == ffi::sqlite3_bind_parameter_count(self.stmt),
|
try!(self.bind_parameters(params));
|
||||||
"incorrect number of parameters to execute(): expected {}, got {}",
|
|
||||||
ffi::sqlite3_bind_parameter_count(self.stmt),
|
|
||||||
params.len());
|
|
||||||
|
|
||||||
for (i, p) in params.iter().enumerate() {
|
|
||||||
try!(self.conn.decode_result(p.bind_parameter(self.stmt, (i + 1) as c_int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.needs_reset = true;
|
self.needs_reset = true;
|
||||||
let r = ffi::sqlite3_step(self.stmt);
|
let r = ffi::sqlite3_step(self.stmt);
|
||||||
@ -660,6 +653,7 @@ impl<'conn> SqliteStatement<'conn> {
|
|||||||
try!(self.bind_parameters(params));
|
try!(self.bind_parameters(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.needs_reset = true;
|
||||||
Ok(SqliteRows::new(self))
|
Ok(SqliteRows::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,8 +692,6 @@ impl<'conn> SqliteStatement<'conn> {
|
|||||||
try!(self.conn.decode_result(p.bind_parameter(self.stmt, (i + 1) as c_int)));
|
try!(self.conn.decode_result(p.bind_parameter(self.stmt, (i + 1) as c_int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.needs_reset = true;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user