Use new closure syntax

This commit is contained in:
John Gallagher 2015-01-07 09:18:14 -05:00
parent c044d1df8f
commit d427ddd7a5

View File

@ -244,7 +244,8 @@ impl SqliteConnection {
/// * The query does not successfully return at least one row.
///
/// If the query returns more than one row, all rows except the first are ignored.
pub fn query_row<T>(&self, sql: &str, params: &[&ToSql], f: |SqliteRow| -> T) -> T {
pub fn query_row<T, F>(&self, sql: &str, params: &[&ToSql], f: F) -> T
where F: FnOnce(SqliteRow) -> T {
let mut stmt = self.prepare(sql).unwrap();
let mut rows = stmt.query(params).unwrap();
f(rows.next().expect("Query did not return a row").unwrap())