mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Cleanup - if let
to match
This commit is contained in:
parent
d7909c086b
commit
30db1905d3
@ -319,10 +319,9 @@ impl SqliteConnection {
|
|||||||
let mut stmt = try!(self.prepare(sql));
|
let mut stmt = try!(self.prepare(sql));
|
||||||
let mut rows = try!(stmt.query(params));
|
let mut rows = try!(stmt.query(params));
|
||||||
|
|
||||||
if let Some(row) = rows.next() {
|
match rows.next() {
|
||||||
row.map(f)
|
Some(row) => row.map(f),
|
||||||
} else {
|
None => Err(SqliteError{
|
||||||
Err(SqliteError{
|
|
||||||
code: ffi::SQLITE_NOTICE,
|
code: ffi::SQLITE_NOTICE,
|
||||||
message: "Query did not return a row".to_string(),
|
message: "Query did not return a row".to_string(),
|
||||||
})
|
})
|
||||||
|
@ -89,10 +89,10 @@ raw_to_impl!(c_double, sqlite3_bind_double);
|
|||||||
|
|
||||||
impl<'a> ToSql for &'a str {
|
impl<'a> ToSql for &'a str {
|
||||||
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
|
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
|
||||||
if let Ok(c_str) = str_to_cstring(self) {
|
match str_to_cstring(self) {
|
||||||
ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1, Some(ffi::SQLITE_TRANSIENT()))
|
Ok(c_str) => ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1,
|
||||||
} else {
|
Some(ffi::SQLITE_TRANSIENT())),
|
||||||
ffi::SQLITE_MISUSE
|
Err(_) => ffi::SQLITE_MISUSE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user