feat(storage): make Database::view accept FnOnce instead of FnMut (#1331)

This commit is contained in:
Alexey Shekhirin
2023-02-14 14:31:58 +08:00
committed by GitHub
parent 5c62149b83
commit 3b732ad0db

View File

@@ -26,9 +26,9 @@ pub trait Database: for<'a> DatabaseGAT<'a> {
/// Takes a function and passes a read-only transaction into it, making sure it's closed in the
/// end of the execution.
fn view<T, F>(&self, mut f: F) -> Result<T, Error>
fn view<T, F>(&self, f: F) -> Result<T, Error>
where
F: FnMut(&<Self as DatabaseGAT<'_>>::TX) -> T,
F: FnOnce(&<Self as DatabaseGAT<'_>>::TX) -> T,
{
let tx = self.tx()?;