diff --git a/substrate/frame/support/src/storage/generator/double_map.rs b/substrate/frame/support/src/storage/generator/double_map.rs index e5ee7ec45b13e69254aa6e4bda2a548170f1e9cf..7e1a2456e4536b7b9da5e69e13a6f6d67ff27d88 100644 --- a/substrate/frame/support/src/storage/generator/double_map.rs +++ b/substrate/frame/support/src/storage/generator/double_map.rs @@ -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) diff --git a/substrate/frame/support/src/storage/generator/map.rs b/substrate/frame/support/src/storage/generator/map.rs index 198fad08dc731a339e06769a47b778f7197d1a2e..7f6eb2a518f578e05dd04e68a8106812cce890ba 100644 --- a/substrate/frame/support/src/storage/generator/map.rs +++ b/substrate/frame/support/src/storage/generator/map.rs @@ -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) diff --git a/substrate/frame/support/src/storage/mod.rs b/substrate/frame/support/src/storage/mod.rs index dbb1062c2463954c2d30c5c6d7fa3b5514977024..93cf7c663906461a72eda5a58d390ebe8b920c17 100644 --- a/substrate/frame/support/src/storage/mod.rs +++ b/substrate/frame/support/src/storage/mod.rs @@ -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. @@ -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. @@ -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) diff --git a/substrate/frame/support/src/storage/types/double_map.rs b/substrate/frame/support/src/storage/types/double_map.rs index 93f40b660f7b851486a41e9c446a5fae4ee62430..f0b5f66eff058e40a0f4f4954f78aac87024f635 100644 --- a/substrate/frame/support/src/storage/types/double_map.rs +++ b/substrate/frame/support/src/storage/types/double_map.rs @@ -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) } } @@ -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) } } diff --git a/substrate/frame/support/src/storage/types/map.rs b/substrate/frame/support/src/storage/types/map.rs index 5c236e7f6b5988e36b8729b6af925210620c52ac..4af28a77cf2b6086323aeee5ac616534fcbc2ae2 100644 --- a/substrate/frame/support/src/storage/types/map.rs +++ b/substrate/frame/support/src/storage/types/map.rs @@ -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) } } @@ -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) } }