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 rows = try!(stmt.query(params));
|
||||
|
||||
if let Some(row) = rows.next() {
|
||||
row.map(f)
|
||||
} else {
|
||||
Err(SqliteError{
|
||||
match rows.next() {
|
||||
Some(row) => row.map(f),
|
||||
None => Err(SqliteError{
|
||||
code: ffi::SQLITE_NOTICE,
|
||||
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 {
|
||||
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
|
||||
if let Ok(c_str) = str_to_cstring(self) {
|
||||
ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1, Some(ffi::SQLITE_TRANSIENT()))
|
||||
} else {
|
||||
ffi::SQLITE_MISUSE
|
||||
match str_to_cstring(self) {
|
||||
Ok(c_str) => ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1,
|
||||
Some(ffi::SQLITE_TRANSIENT())),
|
||||
Err(_) => ffi::SQLITE_MISUSE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user