Reset in Rows's drop impl instead of waiting for the next query

This commit is contained in:
John Gallagher
2016-05-16 14:02:39 -05:00
parent 3a52dd65f0
commit 4a6c7b5329
4 changed files with 12 additions and 24 deletions

View File

@@ -23,16 +23,14 @@ impl<'conn> Statement<'conn> {
/// Return `true` if a query in the SQL statement it executes returns one or more rows
/// and `false` if the SQL returns an empty set.
pub fn exists(&mut self, params: &[&ToSql]) -> Result<bool> {
self.reset_if_needed();
let mut rows = try!(self.query(params));
let exists = {
let mut rows = try!(self.query(params));
match rows.next() {
Some(_) => Ok(true),
None => Ok(false),
Some(_) => true,
None => false,
}
};
self.reset_if_needed();
return exists;
Ok(exists)
}
}