FnMut instead of Fn

This commit is contained in:
Eric Tu 2024-09-10 15:57:50 -04:00
parent eb3843e0cf
commit 16eff253ad
3 changed files with 5 additions and 5 deletions

View File

@ -120,7 +120,7 @@ pub trait ShardStore {
/// essentially the immutable version of `with_checkpoints`.
fn for_each_checkpoint<F>(&self, limit: usize, callback: F) -> Result<(), Self::Error>
where
F: Fn(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>;
F: FnMut(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>;
/// Update the checkpoint having the given identifier by mutating it with the provided
/// function, and persist the updated checkpoint to the data store.
@ -226,7 +226,7 @@ impl<S: ShardStore> ShardStore for &mut S {
fn for_each_checkpoint<F>(&self, limit: usize, callback: F) -> Result<(), Self::Error>
where
F: Fn(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>,
F: FnMut(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>,
{
S::for_each_checkpoint(self, limit, callback)
}

View File

@ -186,7 +186,7 @@ where
}
fn for_each_checkpoint<F>(&self, limit: usize, callback: F) -> Result<(), Self::Error>
where
F: Fn(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>,
F: FnMut(&Self::CheckpointId, &Checkpoint) -> Result<(), Self::Error>,
{
self.cache.for_each_checkpoint(limit, callback)
}

View File

@ -137,9 +137,9 @@ impl<H: Clone, C: Clone + Ord> ShardStore for MemoryShardStore<H, C> {
Ok(())
}
fn for_each_checkpoint<F>(&self, limit: usize, callback: F) -> Result<(), Self::Error>
fn for_each_checkpoint<F>(&self, limit: usize, mut callback: F) -> Result<(), Self::Error>
where
F: Fn(&C, &Checkpoint) -> Result<(), Self::Error>,
F: FnMut(&C, &Checkpoint) -> Result<(), Self::Error>,
{
for (cid, checkpoint) in self.checkpoints.iter().take(limit) {
callback(cid, checkpoint)?