Created
April 30, 2016 19:12
-
-
Save sgrif/95bdbd302124010a0e4dbc39862313f2 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
cache.entry(sql).or_insert_with_result(|sql| { | |
Statement::prepare(&self.raw_connection, &sql) | |
.map(CachedStatement::new) | |
}).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
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()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment