Commit 5c6bede
authored
Unrolled build for #140715
Rollup merge of #140715 - lukaslueg:oncecellsyncdocs, r=tgross35
Clarify &mut-methods' docs on sync::OnceLock
Three small changes to the docs of `sync::OnceLock`:
* The docs for `OnceLock::take()` used to [say](https://doc.rust-lang.org/std/sync/struct.OnceLock.html#method.take) "**Safety** is guaranteed by requiring a mutable reference." (emphasis mine). While technically correct, imho its not necessary to even mention safety - as opposed to unsafety - here: Safety never comes up wrt `OnceLock`, as there is (currently) no way to interact with a `OnceLock` in an unsafe way; there are no unsafe methods on `OnceLock`, so there is "safety" guarantee required anywhere. What we simply meant to say is "**Synchronization** is guaranteed...".
* I've add that phrase to the other methods of `OnceLock` which take a `&mut self`, to highlight the fact that having a `&mut OnceLock` guarantees that synchronization with other threads is not required. This is the same as with [`Mutex::get_mut()`](https://doc.rust-lang.org/std/sync/struct.Mutex.html#method.get_mut), [`Cell::get_mut()`](https://doc.rust-lang.org/std/cell/struct.Cell.html#method.get_mut), and others.
* In that spirit, the half-sentence "or being initialized" was removed from `get_mut()`, as there is no way that the `OnceLock` is being initialized while we are holding `&mut` to it. Probably a copy&paste from `.get()`1 file changed
+13
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| |||
315 | 318 | | |
316 | 319 | | |
317 | 320 | | |
318 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
319 | 324 | | |
320 | 325 | | |
321 | 326 | | |
| |||
405 | 410 | | |
406 | 411 | | |
407 | 412 | | |
408 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
409 | 416 | | |
410 | 417 | | |
411 | 418 | | |
| |||
469 | 476 | | |
470 | 477 | | |
471 | 478 | | |
472 | | - | |
| 479 | + | |
| 480 | + | |
473 | 481 | | |
474 | 482 | | |
475 | 483 | | |
| |||
0 commit comments