Skip to content

Commit 031b2b8

Browse files
committed
Clarify &mut-methods' docs on sync::OnceLock
1 parent 1a95cc6 commit 031b2b8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

library/std/src/sync/once_lock.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ impl<T> OnceLock<T> {
159159

160160
/// Gets the mutable reference to the underlying value.
161161
///
162-
/// Returns `None` if the cell is uninitialized, or being initialized.
163-
/// This method never blocks.
162+
/// Returns `None` if the cell is uninitialized.
163+
/// This method never blocks. Synchronization is guaranteed by requiring
164+
/// a mutable reference.
164165
#[inline]
165166
#[stable(feature = "once_cell", since = "1.70.0")]
166167
pub fn get_mut(&mut self) -> Option<&mut T> {
@@ -315,7 +316,7 @@ impl<T> OnceLock<T> {
315316
/// Gets the mutable reference of the contents of the cell, initializing
316317
/// it to `f()` if the cell was uninitialized.
317318
///
318-
/// This method never blocks.
319+
/// This method never blocks. Synchronization is guaranteed by requiring a mutable reference.
319320
///
320321
/// # Panics
321322
///
@@ -405,7 +406,8 @@ impl<T> OnceLock<T> {
405406
/// it to `f()` if the cell was uninitialized. If the cell was uninitialized
406407
/// and `f()` failed, an error is returned.
407408
///
408-
/// This method never blocks.
409+
/// This method never blocks. Synchronization is guaranteed by requiring a mutable reference.
410+
409411
///
410412
/// # Panics
411413
///
@@ -469,7 +471,7 @@ impl<T> OnceLock<T> {
469471
///
470472
/// Has no effect and returns `None` if the `OnceLock` was uninitialized.
471473
///
472-
/// Safety is guaranteed by requiring a mutable reference.
474+
/// Synchronization is guaranteed by requiring a mutable reference.
473475
///
474476
/// # Examples
475477
///

0 commit comments

Comments
 (0)