mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-06 21:57:22 +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:
@@ -16,11 +16,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{Arc, atomic::{AtomicIsize, Ordering as AtomicOrdering}},
|
||||
sync::{
|
||||
atomic::{AtomicIsize, Ordering as AtomicOrdering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
use parking_lot::{RwLock, RwLockWriteGuard, RwLockReadGuard};
|
||||
|
||||
/// Something that can report its size.
|
||||
pub trait Size {
|
||||
@@ -39,11 +42,7 @@ pub struct TrackedMap<K, V> {
|
||||
|
||||
impl<K, V> Default for TrackedMap<K, V> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
index: Arc::new(HashMap::default().into()),
|
||||
bytes: 0.into(),
|
||||
length: 0.into(),
|
||||
}
|
||||
Self { index: Arc::new(HashMap::default().into()), bytes: 0.into(), length: 0.into() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +64,7 @@ impl<K, V> TrackedMap<K, V> {
|
||||
|
||||
/// Lock map for read.
|
||||
pub fn read(&self) -> TrackedMapReadAccess<K, V> {
|
||||
TrackedMapReadAccess {
|
||||
inner_guard: self.index.read(),
|
||||
}
|
||||
TrackedMapReadAccess { inner_guard: self.index.read() }
|
||||
}
|
||||
|
||||
/// Lock map for write.
|
||||
@@ -87,13 +84,11 @@ pub struct ReadOnlyTrackedMap<K, V>(Arc<RwLock<HashMap<K, V>>>);
|
||||
|
||||
impl<K, V> ReadOnlyTrackedMap<K, V>
|
||||
where
|
||||
K: Eq + std::hash::Hash
|
||||
K: Eq + std::hash::Hash,
|
||||
{
|
||||
/// Lock map for read.
|
||||
pub fn read(&self) -> TrackedMapReadAccess<K, V> {
|
||||
TrackedMapReadAccess {
|
||||
inner_guard: self.0.read(),
|
||||
}
|
||||
TrackedMapReadAccess { inner_guard: self.0.read() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +98,7 @@ pub struct TrackedMapReadAccess<'a, K, V> {
|
||||
|
||||
impl<'a, K, V> TrackedMapReadAccess<'a, K, V>
|
||||
where
|
||||
K: Eq + std::hash::Hash
|
||||
K: Eq + std::hash::Hash,
|
||||
{
|
||||
/// Returns true if map contains key.
|
||||
pub fn contains_key(&self, key: &K) -> bool {
|
||||
@@ -129,7 +124,8 @@ pub struct TrackedMapWriteAccess<'a, K, V> {
|
||||
|
||||
impl<'a, K, V> TrackedMapWriteAccess<'a, K, V>
|
||||
where
|
||||
K: Eq + std::hash::Hash, V: Size
|
||||
K: Eq + std::hash::Hash,
|
||||
V: Size,
|
||||
{
|
||||
/// Insert value and return previous (if any).
|
||||
pub fn insert(&mut self, key: K, val: V) -> Option<V> {
|
||||
@@ -165,7 +161,9 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
impl Size for i32 {
|
||||
fn size(&self) -> usize { *self as usize / 10 }
|
||||
fn size(&self) -> usize {
|
||||
*self as usize / 10
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user