Skip to content

Commit b3ab854

Browse files
committed
fmt
1 parent 62deb50 commit b3ab854

6 files changed

Lines changed: 33 additions & 12 deletions

File tree

‎mea/src/rwlock/mapped_write_guard.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,19 @@ impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> {
293293
/// This method changes the lock from exclusive mode to shared mode atomically,
294294
/// preventing other writers from acquiring the lock in between.
295295
///
296-
/// The returned `MappedRwLockReadGuard` preserves the original mapping to the specific
296+
/// The returned `MappedRwLockReadGuard` preserves the original mapping to the specific
297297
/// component of the data.
298298
///
299299
/// # Examples
300300
///
301301
/// ```
302302
/// # #[tokio::main]
303303
/// # async fn main() {
304-
/// use mea::rwlock::{RwLock, RwLockWriteGuard};
305304
/// use std::sync::Arc;
306305
///
306+
/// use mea::rwlock::RwLock;
307+
/// use mea::rwlock::RwLockWriteGuard;
308+
///
307309
/// #[derive(Debug)]
308310
/// struct Counter {
309311
/// value: i32,

‎mea/src/rwlock/owned_mapped_write_guard.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ impl<T: ?Sized, U: ?Sized> OwnedMappedRwLockWriteGuard<T, U> {
329329
/// # #[tokio::main]
330330
/// # async fn main() {
331331
/// use std::sync::Arc;
332-
/// use mea::rwlock::{RwLock, OwnedRwLockWriteGuard};
332+
///
333+
/// use mea::rwlock::OwnedRwLockWriteGuard;
334+
/// use mea::rwlock::RwLock;
333335
///
334336
/// #[derive(Debug)]
335337
/// struct Database {
@@ -343,7 +345,8 @@ impl<T: ?Sized, U: ?Sized> OwnedMappedRwLockWriteGuard<T, U> {
343345
/// }));
344346
///
345347
/// let write_guard = db.clone().write_owned().await;
346-
/// let mut count_write_guard = OwnedRwLockWriteGuard::map(write_guard, |db| &mut db.connection_count);
348+
/// let mut count_write_guard =
349+
/// OwnedRwLockWriteGuard::map(write_guard, |db| &mut db.connection_count);
347350
/// *count_write_guard = 5;
348351
///
349352
/// let db_clone = db.clone();

‎mea/src/rwlock/owned_write_guard.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,18 @@ impl<T: ?Sized> OwnedRwLockWriteGuard<T> {
278278
/// This method changes the lock from exclusive mode to shared mode atomically,
279279
/// preventing other writers from acquiring the lock in between.
280280
///
281-
/// The returned `OwnedRwLockReadGuard` has a `'static` lifetime, as it keeps
281+
/// The returned `OwnedRwLockReadGuard` has a `'static` lifetime, as it keeps
282282
/// the `RwLock` alive by holding an `Arc`.
283283
///
284284
/// # Examples
285285
///
286286
/// ```
287287
/// # #[tokio::main]
288288
/// # async fn main() {
289-
/// use mea::rwlock::RwLock;
290289
/// use std::sync::Arc;
291290
///
291+
/// use mea::rwlock::RwLock;
292+
///
292293
/// let lock = Arc::new(RwLock::new(1));
293294
///
294295
/// let mut write_guard = lock.clone().write_owned().await;

‎mea/src/rwlock/read_guard.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ impl<'a, T: ?Sized> RwLockReadGuard<'a, T> {
146146
/// acquiring a new semaphore permit, as it relies on the permit
147147
/// already held by the `RwLockWriteGuard`.
148148
pub(super) fn from_write_downgrade(write_guard: ManuallyDrop<RwLockWriteGuard<'a, T>>) -> Self {
149-
Self { lock: write_guard.lock }
149+
Self {
150+
lock: write_guard.lock,
151+
}
150152
}
151153
/// Makes a new [`MappedRwLockReadGuard`] for a component of the locked data.
152154
///

‎mea/src/rwlock/test.rs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,11 @@ async fn test_downgrade_allows_concurrent_readers() {
815815

816816
for handle in reader_handles {
817817
let (reader_id, value) = handle.await.unwrap();
818-
assert_eq!(value, 42, "Reader {} should see the written value", reader_id);
818+
assert_eq!(
819+
value, 42,
820+
"Reader {} should see the written value",
821+
reader_id
822+
);
819823
}
820824
}
821825
#[tokio::test]
@@ -1034,7 +1038,11 @@ async fn test_owned_write_guard_downgrade_no_memory_leak() {
10341038

10351039
drop(rwlock);
10361040

1037-
assert_eq!(weak_ref.strong_count(), 0, "Memory leak detected in OwnedRwLockWriteGuard downgrade!");
1041+
assert_eq!(
1042+
weak_ref.strong_count(),
1043+
0,
1044+
"Memory leak detected in OwnedRwLockWriteGuard downgrade!"
1045+
);
10381046
}
10391047

10401048
#[tokio::test]
@@ -1055,5 +1063,9 @@ async fn test_owned_mapped_write_guard_downgrade_no_memory_leak() {
10551063

10561064
drop(rwlock);
10571065

1058-
assert_eq!(weak_ref.strong_count(), 0, "Memory leak detected in OwnedMappedRwLockWriteGuard downgrade!");
1066+
assert_eq!(
1067+
weak_ref.strong_count(),
1068+
0,
1069+
"Memory leak detected in OwnedMappedRwLockWriteGuard downgrade!"
1070+
);
10591071
}

‎mea/src/rwlock/write_guard.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,10 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> {
258258
/// ```
259259
/// # #[tokio::main]
260260
/// # async fn main() {
261-
/// use mea::rwlock::RwLock;
262261
/// use std::sync::Arc;
263262
///
263+
/// use mea::rwlock::RwLock;
264+
///
264265
/// let lock = Arc::new(RwLock::new(1));
265266
///
266267
/// let mut write_guard = lock.write().await;
@@ -300,4 +301,4 @@ impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> {
300301

301302
RwLockReadGuard::from_write_downgrade(guard)
302303
}
303-
}
304+
}

0 commit comments

Comments
 (0)