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

Remove unnecessary Clone trait bounds on CountedStorageMap #12402

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions frame/support/src/storage/types/counted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
}

/// Store a value to be associated with the given key from the map.
pub fn insert<KeyArg: EncodeLike<Key> + Clone, ValArg: EncodeLike<Value>>(
pub fn insert<KeyArg: EncodeLike<Key>, ValArg: EncodeLike<Value>>(
key: KeyArg,
val: ValArg,
) {
Expand All @@ -154,15 +154,15 @@ where
}

/// Remove the value under a key.
pub fn remove<KeyArg: EncodeLike<Key> + Clone>(key: KeyArg) {
pub fn remove<KeyArg: EncodeLike<Key>>(key: KeyArg) {
if <Self as MapWrapper>::Map::contains_key(Ref::from(&key)) {
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
}
<Self as MapWrapper>::Map::remove(key)
}

/// Mutate the value under a key.
pub fn mutate<KeyArg: EncodeLike<Key> + Clone, R, F: FnOnce(&mut QueryKind::Query) -> R>(
pub fn mutate<KeyArg: EncodeLike<Key>, R, F: FnOnce(&mut QueryKind::Query) -> R>(
key: KeyArg,
f: F,
) -> R {
Expand All @@ -173,7 +173,7 @@ where
/// Mutate the item, only if an `Ok` value is returned.
pub fn try_mutate<KeyArg, R, E, F>(key: KeyArg, f: F) -> Result<R, E>
where
KeyArg: EncodeLike<Key> + Clone,
KeyArg: EncodeLike<Key>,
F: FnOnce(&mut QueryKind::Query) -> Result<R, E>,
{
Self::try_mutate_exists(key, |option_value_ref| {
Expand All @@ -187,7 +187,7 @@ where
}

/// Mutate the value under a key. Deletes the item if mutated to a `None`.
pub fn mutate_exists<KeyArg: EncodeLike<Key> + Clone, R, F: FnOnce(&mut Option<Value>) -> R>(
pub fn mutate_exists<KeyArg: EncodeLike<Key>, R, F: FnOnce(&mut Option<Value>) -> R>(
key: KeyArg,
f: F,
) -> R {
Expand All @@ -200,7 +200,7 @@ where
/// or if the storage item does not exist (`None`), independent of the `QueryType`.
pub fn try_mutate_exists<KeyArg, R, E, F>(key: KeyArg, f: F) -> Result<R, E>
where
KeyArg: EncodeLike<Key> + Clone,
KeyArg: EncodeLike<Key>,
F: FnOnce(&mut Option<Value>) -> Result<R, E>,
{
<Self as MapWrapper>::Map::try_mutate_exists(key, |option_value| {
Expand All @@ -222,7 +222,7 @@ where
}

/// Take the value under a key.
pub fn take<KeyArg: EncodeLike<Key> + Clone>(key: KeyArg) -> QueryKind::Query {
pub fn take<KeyArg: EncodeLike<Key>>(key: KeyArg) -> QueryKind::Query {
let removed_value = <Self as MapWrapper>::Map::mutate_exists(key, |value| value.take());
if removed_value.is_some() {
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
Expand All @@ -240,7 +240,7 @@ where
/// `[item]`. Any default value set for the storage item will be ignored on overwrite.
pub fn append<Item, EncodeLikeItem, EncodeLikeKey>(key: EncodeLikeKey, item: EncodeLikeItem)
where
EncodeLikeKey: EncodeLike<Key> + Clone,
EncodeLikeKey: EncodeLike<Key>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
Value: StorageAppend<Item>,
Expand Down Expand Up @@ -355,7 +355,7 @@ where
/// Is only available if `Value` of the storage implements [`StorageTryAppend`].
pub fn try_append<KArg, Item, EncodeLikeItem>(key: KArg, item: EncodeLikeItem) -> Result<(), ()>
where
KArg: EncodeLike<Key> + Clone,
KArg: EncodeLike<Key>,
Item: Encode,
EncodeLikeItem: EncodeLike<Item>,
Value: StorageTryAppend<Item>,
Expand Down