From: Elias Rohrer Date: Tue, 17 Sep 2024 11:05:40 +0000 (+0200) Subject: `rustfmt`: Run on `sync/nostd_sync.rs` X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e3fb566e0581261b72d9a27ce51f713ec7734962;p=rust-lightning `rustfmt`: Run on `sync/nostd_sync.rs` --- diff --git a/lightning/src/sync/nostd_sync.rs b/lightning/src/sync/nostd_sync.rs index 0f92bd6ca..03fa65b69 100644 --- a/lightning/src/sync/nostd_sync.rs +++ b/lightning/src/sync/nostd_sync.rs @@ -1,12 +1,12 @@ -pub use ::alloc::sync::Arc; +use super::{LockHeldState, LockTestExt}; +pub use alloc::sync::Arc; +use core::cell::{Ref, RefCell, RefMut}; use core::ops::{Deref, DerefMut}; -use core::cell::{RefCell, Ref, RefMut}; -use super::{LockTestExt, LockHeldState}; pub type LockResult = Result; pub struct Mutex { - inner: RefCell + inner: RefCell, } #[must_use = "if unused the Mutex will immediately unlock"] @@ -45,16 +45,21 @@ impl Mutex { impl<'a, T: 'a> LockTestExt<'a> for Mutex { #[inline] fn held_by_thread(&self) -> LockHeldState { - if self.inner.try_borrow_mut().is_err() { return LockHeldState::HeldByThread; } - else { return LockHeldState::NotHeldByThread; } + if self.inner.try_borrow_mut().is_err() { + return LockHeldState::HeldByThread; + } else { + return LockHeldState::NotHeldByThread; + } } type ExclLock = MutexGuard<'a, T>; #[inline] - fn unsafe_well_ordered_double_lock_self(&'a self) -> MutexGuard { self.lock().unwrap() } + fn unsafe_well_ordered_double_lock_self(&'a self) -> MutexGuard { + self.lock().unwrap() + } } pub struct RwLock { - inner: RefCell + inner: RefCell, } pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { @@ -103,7 +108,7 @@ impl RwLock { pub fn try_write<'a>(&'a self) -> LockResult> { match self.inner.try_borrow_mut() { Ok(lock) => Ok(RwLockWriteGuard { lock }), - Err(_) => Err(()) + Err(_) => Err(()), } } } @@ -111,12 +116,17 @@ impl RwLock { impl<'a, T: 'a> LockTestExt<'a> for RwLock { #[inline] fn held_by_thread(&self) -> LockHeldState { - if self.inner.try_borrow_mut().is_err() { return LockHeldState::HeldByThread; } - else { return LockHeldState::NotHeldByThread; } + if self.inner.try_borrow_mut().is_err() { + return LockHeldState::HeldByThread; + } else { + return LockHeldState::NotHeldByThread; + } } type ExclLock = RwLockWriteGuard<'a, T>; #[inline] - fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard { self.write().unwrap() } + fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard { + self.write().unwrap() + } } pub type FairRwLock = RwLock;