mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Remove unnecessary Clone trait bounds on CountedStorageMap (#12402)
* Remove unnecessary Clone trait bounds on CountedStorageMap * cargo fmt
This commit is contained in:
@@ -143,10 +143,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Store a value to be associated with the given key from the map.
|
/// 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) {
|
||||||
key: KeyArg,
|
|
||||||
val: ValArg,
|
|
||||||
) {
|
|
||||||
if !<Self as MapWrapper>::Map::contains_key(Ref::from(&key)) {
|
if !<Self as MapWrapper>::Map::contains_key(Ref::from(&key)) {
|
||||||
CounterFor::<Prefix>::mutate(|value| value.saturating_inc());
|
CounterFor::<Prefix>::mutate(|value| value.saturating_inc());
|
||||||
}
|
}
|
||||||
@@ -154,7 +151,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the value under a key.
|
/// 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)) {
|
if <Self as MapWrapper>::Map::contains_key(Ref::from(&key)) {
|
||||||
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
|
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
|
||||||
}
|
}
|
||||||
@@ -162,7 +159,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Mutate the value under a 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,
|
key: KeyArg,
|
||||||
f: F,
|
f: F,
|
||||||
) -> R {
|
) -> R {
|
||||||
@@ -173,7 +170,7 @@ where
|
|||||||
/// Mutate the item, only if an `Ok` value is returned.
|
/// 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>
|
pub fn try_mutate<KeyArg, R, E, F>(key: KeyArg, f: F) -> Result<R, E>
|
||||||
where
|
where
|
||||||
KeyArg: EncodeLike<Key> + Clone,
|
KeyArg: EncodeLike<Key>,
|
||||||
F: FnOnce(&mut QueryKind::Query) -> Result<R, E>,
|
F: FnOnce(&mut QueryKind::Query) -> Result<R, E>,
|
||||||
{
|
{
|
||||||
Self::try_mutate_exists(key, |option_value_ref| {
|
Self::try_mutate_exists(key, |option_value_ref| {
|
||||||
@@ -187,7 +184,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Mutate the value under a key. Deletes the item if mutated to a `None`.
|
/// 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,
|
key: KeyArg,
|
||||||
f: F,
|
f: F,
|
||||||
) -> R {
|
) -> R {
|
||||||
@@ -200,7 +197,7 @@ where
|
|||||||
/// or if the storage item does not exist (`None`), independent of the `QueryType`.
|
/// 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>
|
pub fn try_mutate_exists<KeyArg, R, E, F>(key: KeyArg, f: F) -> Result<R, E>
|
||||||
where
|
where
|
||||||
KeyArg: EncodeLike<Key> + Clone,
|
KeyArg: EncodeLike<Key>,
|
||||||
F: FnOnce(&mut Option<Value>) -> Result<R, E>,
|
F: FnOnce(&mut Option<Value>) -> Result<R, E>,
|
||||||
{
|
{
|
||||||
<Self as MapWrapper>::Map::try_mutate_exists(key, |option_value| {
|
<Self as MapWrapper>::Map::try_mutate_exists(key, |option_value| {
|
||||||
@@ -222,7 +219,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Take the value under a key.
|
/// 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());
|
let removed_value = <Self as MapWrapper>::Map::mutate_exists(key, |value| value.take());
|
||||||
if removed_value.is_some() {
|
if removed_value.is_some() {
|
||||||
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
|
CounterFor::<Prefix>::mutate(|value| value.saturating_dec());
|
||||||
@@ -240,7 +237,7 @@ where
|
|||||||
/// `[item]`. Any default value set for the storage item will be ignored on overwrite.
|
/// `[item]`. Any default value set for the storage item will be ignored on overwrite.
|
||||||
pub fn append<Item, EncodeLikeItem, EncodeLikeKey>(key: EncodeLikeKey, item: EncodeLikeItem)
|
pub fn append<Item, EncodeLikeItem, EncodeLikeKey>(key: EncodeLikeKey, item: EncodeLikeItem)
|
||||||
where
|
where
|
||||||
EncodeLikeKey: EncodeLike<Key> + Clone,
|
EncodeLikeKey: EncodeLike<Key>,
|
||||||
Item: Encode,
|
Item: Encode,
|
||||||
EncodeLikeItem: EncodeLike<Item>,
|
EncodeLikeItem: EncodeLike<Item>,
|
||||||
Value: StorageAppend<Item>,
|
Value: StorageAppend<Item>,
|
||||||
@@ -355,7 +352,7 @@ where
|
|||||||
/// Is only available if `Value` of the storage implements [`StorageTryAppend`].
|
/// Is only available if `Value` of the storage implements [`StorageTryAppend`].
|
||||||
pub fn try_append<KArg, Item, EncodeLikeItem>(key: KArg, item: EncodeLikeItem) -> Result<(), ()>
|
pub fn try_append<KArg, Item, EncodeLikeItem>(key: KArg, item: EncodeLikeItem) -> Result<(), ()>
|
||||||
where
|
where
|
||||||
KArg: EncodeLike<Key> + Clone,
|
KArg: EncodeLike<Key>,
|
||||||
Item: Encode,
|
Item: Encode,
|
||||||
EncodeLikeItem: EncodeLike<Item>,
|
EncodeLikeItem: EncodeLike<Item>,
|
||||||
Value: StorageTryAppend<Item>,
|
Value: StorageTryAppend<Item>,
|
||||||
|
|||||||
Reference in New Issue
Block a user