Created
April 17, 2016 18:35
-
-
Save sgrif/68cbba9a87084da3a2e8c42a12e7d6cf to your computer and use it in GitHub Desktop.
This file contains 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 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