Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

relax translate closure to FnMut #8019

Merged
1 commit merged into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/support/src/storage/generator/double_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl<
iterator
}

fn translate<O: Decode, F: Fn(K1, K2, O) -> Option<V>>(f: F) {
fn translate<O: Decode, F: FnMut(K1, K2, O) -> Option<V>>(mut f: F) {
let prefix = G::prefix_hash();
let mut previous_key = prefix.clone();
while let Some(next) = sp_io::storage::next_key(&previous_key)
Expand Down
2 changes: 1 addition & 1 deletion frame/support/src/storage/generator/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<
iterator
}

fn translate<O: Decode, F: Fn(K, O) -> Option<V>>(f: F) {
fn translate<O: Decode, F: FnMut(K, O) -> Option<V>>(mut f: F) {
let prefix = G::prefix_hash();
let mut previous_key = prefix.clone();
while let Some(next) = sp_io::storage::next_key(&previous_key)
Expand Down
6 changes: 3 additions & 3 deletions frame/support/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub trait IterableStorageMap<K: FullEncode, V: FullCodec>: StorageMap<K, V> {
/// By returning `None` from `f` for an element, you'll remove it from the map.
///
/// NOTE: If a value fail to decode because storage is corrupted then it is skipped.
fn translate<O: Decode, F: Fn(K, O) -> Option<V>>(f: F);
fn translate<O: Decode, F: FnMut(K, O) -> Option<V>>(f: F);
}

/// A strongly-typed double map in storage whose secondary keys and values can be iterated over.
Expand Down Expand Up @@ -352,7 +352,7 @@ pub trait IterableStorageDoubleMap<
/// By returning `None` from `f` for an element, you'll remove it from the map.
///
/// NOTE: If a value fail to decode because storage is corrupted then it is skipped.
fn translate<O: Decode, F: Fn(K1, K2, O) -> Option<V>>(f: F);
fn translate<O: Decode, F: FnMut(K1, K2, O) -> Option<V>>(f: F);
}

/// An implementation of a map with a two keys.
Expand Down Expand Up @@ -614,7 +614,7 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
/// # Usage
///
/// This would typically be called inside the module implementation of on_runtime_upgrade.
fn translate_values<OldValue: Decode, F: Fn(OldValue) -> Option<Value>>(f: F) {
fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(mut f: F) {
let prefix = Self::final_prefix();
let mut previous_key = prefix.clone().to_vec();
while let Some(next) = sp_io::storage::next_key(&previous_key)
Expand Down
4 changes: 2 additions & 2 deletions frame/support/src/storage/types/double_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ where
/// # Usage
///
/// This would typically be called inside the module implementation of on_runtime_upgrade.
pub fn translate_values<OldValue: Decode, F: Fn(OldValue) -> Option<Value>>(f: F) {
pub fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(f: F) {
<Self as crate::storage::StoragePrefixedMap<Value>>::translate_values(f)
}
}
Expand Down Expand Up @@ -379,7 +379,7 @@ where
/// By returning `None` from `f` for an element, you'll remove it from the map.
///
/// NOTE: If a value fail to decode because storage is corrupted then it is skipped.
pub fn translate<O: Decode, F: Fn(Key1, Key2, O) -> Option<Value>>(f: F) {
pub fn translate<O: Decode, F: FnMut(Key1, Key2, O) -> Option<Value>>(f: F) {
<Self as crate::storage::IterableStorageDoubleMap<Key1, Key2, Value>>::translate(f)
}
}
Expand Down
4 changes: 2 additions & 2 deletions frame/support/src/storage/types/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ where
/// # Usage
///
/// This would typically be called inside the module implementation of on_runtime_upgrade.
pub fn translate_values<OldValue: Decode, F: Fn(OldValue) -> Option<Value>>(f: F) {
pub fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(f: F) {
<Self as crate::storage::StoragePrefixedMap<Value>>::translate_values(f)
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ where
/// By returning `None` from `f` for an element, you'll remove it from the map.
///
/// NOTE: If a value fail to decode because storage is corrupted then it is skipped.
pub fn translate<O: Decode, F: Fn(Key, O) -> Option<Value>>(f: F) {
pub fn translate<O: Decode, F: FnMut(Key, O) -> Option<Value>>(f: F) {
<Self as crate::storage::IterableStorageMap<Key, Value>>::translate(f)
}
}
Expand Down