Remove useless clones in sqlite
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Alex 2022-06-06 17:06:22 +02:00
parent 1f9a371b9a
commit e42c7bed38
Signed by: lx
GPG Key ID: 0E496D15096376BE
1 changed files with 4 additions and 4 deletions

View File

@ -48,10 +48,10 @@ impl SqliteDb {
}
impl SqliteDbInner {
fn get_tree(&self, i: usize) -> Result<String> {
fn get_tree(&self, i: usize) -> Result<&'_ str> {
self.trees
.get(i)
.cloned()
.map(String::as_str)
.ok_or_else(|| Error("invalid tree id".into()))
}
}
@ -269,8 +269,8 @@ struct SqliteTx<'a> {
}
impl<'a> SqliteTx<'a> {
fn get_tree(&self, i: usize) -> Result<String> {
self.trees.get(i).cloned().ok_or_else(|| {
fn get_tree(&self, i: usize) -> Result<&'_ str> {
self.trees.get(i).map(String::as_ref).ok_or_else(|| {
Error(
"invalid tree id (it might have been openned after the transaction started)".into(),
)