Cleanup - if let to match

This commit is contained in:
John Gallagher 2015-03-10 16:07:38 -04:00
parent d7909c086b
commit 30db1905d3
2 changed files with 7 additions and 8 deletions

View File

@ -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(),
}) })

View File

@ -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,
} }
} }
} }