Immutable For Each on ShardStore Checkpoints #112
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The only ways to iterate over Checkpoints in the ShardStore is
with_checkpoints
method. The problem with this is that it require a mut reference to the store which isn't always available (e.g. in serialization).min_checkpoint_id
and themax_checkpoint_id
and then casting that to some primitive type ifCheckpointId
isFrom/To <numeric>
then callingget_checkpoint
over the range of that (very not ergonomic!!!).This PR introduces
for_each_checkpoint
which is literally the same aswith_checkpoints
but takes an immutable reference to the store.I actually wanted to rename
with_checkpoints
tofor_each_checkpoint_mut
and call thisfor_each_checkpoint
OR call themwith_checkpoints
andwith_checkpoints_mut
but I didn't want to make a breaking API change!