diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-06 17:06:22 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-06 17:06:22 +0200 |
commit | e42c7bed386f604b5beeb0a4330defacff059233 (patch) | |
tree | 9c27c324883eb527557529836d4b3f37b70a54d0 | |
parent | 1f9a371b9a51ac0288b0137660b06a171853909b (diff) | |
download | garage-e42c7bed386f604b5beeb0a4330defacff059233.tar.gz garage-e42c7bed386f604b5beeb0a4330defacff059233.zip |
Remove useless clones in sqlite
-rw-r--r-- | src/db/sqlite_adapter.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index f0bca257..0c8a0746 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -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(), ) |