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

View File

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