Skip to content

Commit 0758e19

Browse files
committed
clean up some documentation
Signed-off-by: Connor Tsui <[email protected]>
1 parent a61c8be commit 0758e19

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

library/std/src/sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
//! most one thread at a time is able to access some data.
143143
//!
144144
//! - [`Once`]: Used for a thread-safe, one-time global initialization routine.
145-
//! Mostly useful for implementing other types like `OnceLock`.
145+
//! Mostly useful for implementing other types like [`OnceLock`].
146146
//!
147147
//! - [`OnceLock`]: Used for thread-safe, one-time initialization of a
148148
//! variable, with potentially different initializers based on the caller.

library/std/src/sync/poison.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
//! the panics are recognized reliably or on a best-effort basis depend on the
1414
//! primitive. See [Overview](#overview) below.
1515
//!
16-
//! For the alternative implementations that do not employ poisoning,
17-
//! see [`std::sync::nonpoison`].
16+
//! The synchronization objects in this module have alternative implementations that do not employ
17+
//! poisoning in the [`std::sync::nonpoison`] module.
1818
//!
1919
//! [`std::sync::nonpoison`]: crate::sync::nonpoison
2020
//!
@@ -42,14 +42,6 @@
4242
//! [`Mutex::lock()`] returns a [`LockResult`], providing a way to deal with
4343
//! the poisoned state. See [`Mutex`'s documentation](Mutex#poisoning) for more.
4444
//!
45-
//! - [`Once`]: A thread-safe way to run a piece of code only once.
46-
//! Mostly useful for implementing one-time global initialization.
47-
//!
48-
//! [`Once`] is reliably poisoned if the piece of code passed to
49-
//! [`Once::call_once()`] or [`Once::call_once_force()`] panics.
50-
//! When in poisoned state, subsequent calls to [`Once::call_once()`] will panic too.
51-
//! [`Once::call_once_force()`] can be used to clear the poisoned state.
52-
//!
5345
//! - [`RwLock`]: Provides a mutual exclusion mechanism which allows
5446
//! multiple readers at the same time, while allowing only one
5547
//! writer at a time. In some cases, this can be more efficient than
@@ -59,6 +51,11 @@
5951
//! Note, however, that an `RwLock` may only be poisoned if a panic occurs
6052
//! while it is locked exclusively (write mode). If a panic occurs in any reader,
6153
//! then the lock will not be poisoned.
54+
//!
55+
//! Note that the [`Once`] type also employs poisoning, but since it has non-poisoning `force`
56+
//! methods available on it, there is no separate `nonpoison` and `poison` version.
57+
//!
58+
//! [`Once`]: crate::sync::Once
6259
6360
// If we are not unwinding, `PoisonError` is uninhabited.
6461
#![cfg_attr(not(panic = "unwind"), expect(unreachable_code))]

0 commit comments

Comments
 (0)