Add Statement.query_row convenient method (#179)

This commit is contained in:
gwenn
2016-07-14 06:27:46 +02:00
committed by John Gallagher
parent a0b0f77b3e
commit bc71c58387
2 changed files with 32 additions and 5 deletions

View File

@@ -306,9 +306,7 @@ impl Connection {
where F: FnOnce(&Row) -> T
{
let mut stmt = try!(self.prepare(sql));
let mut rows = try!(stmt.query(params));
rows.get_expected_row().map(|r| f(&r))
stmt.query_row(params, f)
}
/// Convenience method to execute a query that is expected to return a single row,