@@ -159,8 +159,11 @@ impl<T> OnceLock<T> {
159
159
160
160
/// Gets the mutable reference to the underlying value.
161
161
///
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
+ ///
164
+ /// This method never blocks. Since it borrows the `OnceLock` mutably,
165
+ /// it is statically guaranteed that no active borrows to the `OnceLock`
166
+ /// exist, including from other threads.
164
167
#[ inline]
165
168
#[ stable( feature = "once_cell" , since = "1.70.0" ) ]
166
169
pub fn get_mut ( & mut self ) -> Option < & mut T > {
@@ -315,7 +318,9 @@ impl<T> OnceLock<T> {
315
318
/// Gets the mutable reference of the contents of the cell, initializing
316
319
/// it to `f()` if the cell was uninitialized.
317
320
///
318
- /// This method never blocks.
321
+ /// This method never blocks. Since it borrows the `OnceLock` mutably,
322
+ /// it is statically guaranteed that no active borrows to the `OnceLock`
323
+ /// exist, including from other threads.
319
324
///
320
325
/// # Panics
321
326
///
@@ -405,7 +410,9 @@ impl<T> OnceLock<T> {
405
410
/// it to `f()` if the cell was uninitialized. If the cell was uninitialized
406
411
/// and `f()` failed, an error is returned.
407
412
///
408
- /// This method never blocks.
413
+ /// This method never blocks. Since it borrows the `OnceLock` mutably,
414
+ /// it is statically guaranteed that no active borrows to the `OnceLock`
415
+ /// exist, including from other threads.
409
416
///
410
417
/// # Panics
411
418
///
@@ -469,7 +476,8 @@ impl<T> OnceLock<T> {
469
476
///
470
477
/// Has no effect and returns `None` if the `OnceLock` was uninitialized.
471
478
///
472
- /// Safety is guaranteed by requiring a mutable reference.
479
+ /// Since this method borrows the `OnceLock` mutably, it is statically guaranteed that
480
+ /// no active borrows to the `OnceLock` exist, including from other threads.
473
481
///
474
482
/// # Examples
475
483
///
0 commit comments