mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-13 15:05:50 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -17,10 +17,9 @@
|
||||
|
||||
//! Traits and associated datatypes for managing abstract stored values.
|
||||
|
||||
use crate::{storage::StorageMap, traits::misc::HandleLifetime};
|
||||
use codec::FullCodec;
|
||||
use sp_runtime::DispatchError;
|
||||
use crate::storage::StorageMap;
|
||||
use crate::traits::misc::HandleLifetime;
|
||||
|
||||
/// An abstraction of a value stored within storage, but possibly as part of a larger composite
|
||||
/// item.
|
||||
@@ -47,25 +46,26 @@ pub trait StoredMap<K, T: Default> {
|
||||
let r = f(&mut account);
|
||||
*x = Some(account);
|
||||
r
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/// Mutate the item, removing or resetting to default value if it has been mutated to `None`.
|
||||
///
|
||||
/// This is infallible as long as the value does not get destroyed.
|
||||
fn mutate_exists<R>(
|
||||
k: &K,
|
||||
f: impl FnOnce(&mut Option<T>) -> R,
|
||||
) -> Result<R, DispatchError> {
|
||||
fn mutate_exists<R>(k: &K, f: impl FnOnce(&mut Option<T>) -> R) -> Result<R, DispatchError> {
|
||||
Self::try_mutate_exists(k, |x| -> Result<R, DispatchError> { Ok(f(x)) })
|
||||
}
|
||||
|
||||
/// Set the item to something new.
|
||||
fn insert(k: &K, t: T) -> Result<(), DispatchError> { Self::mutate(k, |i| *i = t) }
|
||||
fn insert(k: &K, t: T) -> Result<(), DispatchError> {
|
||||
Self::mutate(k, |i| *i = t)
|
||||
}
|
||||
|
||||
/// Remove the item or otherwise replace it with its default value; we don't care which.
|
||||
fn remove(k: &K) -> Result<(), DispatchError> { Self::mutate_exists(k, |x| *x = None) }
|
||||
fn remove(k: &K) -> Result<(), DispatchError> {
|
||||
Self::mutate_exists(k, |x| *x = None)
|
||||
}
|
||||
}
|
||||
|
||||
/// A shim for placing around a storage item in order to use it as a `StoredValue`. Ideally this
|
||||
@@ -81,12 +81,15 @@ pub trait StoredMap<K, T: Default> {
|
||||
/// system module's `CallOnCreatedAccount` and `CallKillAccount`.
|
||||
pub struct StorageMapShim<S, L, K, T>(sp_std::marker::PhantomData<(S, L, K, T)>);
|
||||
impl<
|
||||
S: StorageMap<K, T, Query=T>,
|
||||
L: HandleLifetime<K>,
|
||||
K: FullCodec,
|
||||
T: FullCodec + Default,
|
||||
> StoredMap<K, T> for StorageMapShim<S, L, K, T> {
|
||||
fn get(k: &K) -> T { S::get(k) }
|
||||
S: StorageMap<K, T, Query = T>,
|
||||
L: HandleLifetime<K>,
|
||||
K: FullCodec,
|
||||
T: FullCodec + Default,
|
||||
> StoredMap<K, T> for StorageMapShim<S, L, K, T>
|
||||
{
|
||||
fn get(k: &K) -> T {
|
||||
S::get(k)
|
||||
}
|
||||
fn insert(k: &K, t: T) -> Result<(), DispatchError> {
|
||||
if !S::contains_key(&k) {
|
||||
L::created(k)?;
|
||||
|
||||
Reference in New Issue
Block a user