Created
April 17, 2016 18:35
-
-
Save sgrif/52fd3d149324858420aedbf4f8f8580e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match cache.entry(sql) { | |
Occupied(entry) => Ok(entry.get().clone()), | |
Vacant(entry) => { | |
let statement = try!(Statement::prepare(&self.raw_connection, entry.key())); | |
Ok(entry.insert(CachedStatement::new(statement)).clone()) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if cache.contains_key(&sql) { | |
Ok(cache[&sql].clone()) | |
} else { | |
let statement = try!(Statement::prepare(&self.raw_connection, &sql)); | |
let entry = cache.entry(sql); | |
Ok(entry.or_insert(CachedStatement::new(statement)).clone()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment