@@ -159,8 +159,11 @@ 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+ ///
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.
164167 #[ inline]
165168 #[ stable( feature = "once_cell" , since = "1.70.0" ) ]
166169 pub fn get_mut ( & mut self ) -> Option < & mut T > {
@@ -315,7 +318,9 @@ impl<T> OnceLock<T> {
315318 /// Gets the mutable reference of the contents of the cell, initializing
316319 /// it to `f()` if the cell was uninitialized.
317320 ///
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.
319324 ///
320325 /// # Panics
321326 ///
@@ -405,7 +410,9 @@ impl<T> OnceLock<T> {
405410 /// it to `f()` if the cell was uninitialized. If the cell was uninitialized
406411 /// and `f()` failed, an error is returned.
407412 ///
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.
409416 ///
410417 /// # Panics
411418 ///
@@ -469,7 +476,8 @@ impl<T> OnceLock<T> {
469476 ///
470477 /// Has no effect and returns `None` if the `OnceLock` was uninitialized.
471478 ///
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.
473481 ///
474482 /// # Examples
475483 ///
0 commit comments