diff --git a/src/lib.rs b/src/lib.rs index a513467..7f42249 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(), }) diff --git a/src/types.rs b/src/types.rs index fb255b3..669fad4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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, } } }