Skip to content

Commit e3fb566

Browse files
committed
rustfmt: Run on sync/nostd_sync.rs
1 parent a161834 commit e3fb566

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

lightning/src/sync/nostd_sync.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
pub use ::alloc::sync::Arc;
1+
use super::{LockHeldState, LockTestExt};
2+
pub use alloc::sync::Arc;
3+
use core::cell::{Ref, RefCell, RefMut};
24
use core::ops::{Deref, DerefMut};
3-
use core::cell::{RefCell, Ref, RefMut};
4-
use super::{LockTestExt, LockHeldState};
55

66
pub type LockResult<Guard> = Result<Guard, ()>;
77

88
pub struct Mutex<T: ?Sized> {
9-
inner: RefCell<T>
9+
inner: RefCell<T>,
1010
}
1111

1212
#[must_use = "if unused the Mutex will immediately unlock"]
@@ -45,16 +45,21 @@ impl<T> Mutex<T> {
4545
impl<'a, T: 'a> LockTestExt<'a> for Mutex<T> {
4646
#[inline]
4747
fn held_by_thread(&self) -> LockHeldState {
48-
if self.inner.try_borrow_mut().is_err() { return LockHeldState::HeldByThread; }
49-
else { return LockHeldState::NotHeldByThread; }
48+
if self.inner.try_borrow_mut().is_err() {
49+
return LockHeldState::HeldByThread;
50+
} else {
51+
return LockHeldState::NotHeldByThread;
52+
}
5053
}
5154
type ExclLock = MutexGuard<'a, T>;
5255
#[inline]
53-
fn unsafe_well_ordered_double_lock_self(&'a self) -> MutexGuard<T> { self.lock().unwrap() }
56+
fn unsafe_well_ordered_double_lock_self(&'a self) -> MutexGuard<T> {
57+
self.lock().unwrap()
58+
}
5459
}
5560

5661
pub struct RwLock<T: ?Sized> {
57-
inner: RefCell<T>
62+
inner: RefCell<T>,
5863
}
5964

6065
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
@@ -103,20 +108,25 @@ impl<T> RwLock<T> {
103108
pub fn try_write<'a>(&'a self) -> LockResult<RwLockWriteGuard<'a, T>> {
104109
match self.inner.try_borrow_mut() {
105110
Ok(lock) => Ok(RwLockWriteGuard { lock }),
106-
Err(_) => Err(())
111+
Err(_) => Err(()),
107112
}
108113
}
109114
}
110115

111116
impl<'a, T: 'a> LockTestExt<'a> for RwLock<T> {
112117
#[inline]
113118
fn held_by_thread(&self) -> LockHeldState {
114-
if self.inner.try_borrow_mut().is_err() { return LockHeldState::HeldByThread; }
115-
else { return LockHeldState::NotHeldByThread; }
119+
if self.inner.try_borrow_mut().is_err() {
120+
return LockHeldState::HeldByThread;
121+
} else {
122+
return LockHeldState::NotHeldByThread;
123+
}
116124
}
117125
type ExclLock = RwLockWriteGuard<'a, T>;
118126
#[inline]
119-
fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard<T> { self.write().unwrap() }
127+
fn unsafe_well_ordered_double_lock_self(&'a self) -> RwLockWriteGuard<T> {
128+
self.write().unwrap()
129+
}
120130
}
121131

122132
pub type FairRwLock<T> = RwLock<T>;

0 commit comments

Comments
 (0)