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