Rollup merge of #82645 - rkjnsn:patch-3, r=Mark-Simulacrum

Clarify that SyncOnceCell::set blocks.

Reading the discussion of this feature, I gained the mistaken impression that neither `set` nor `get` blocked, and thus calling `get` immediately after `set` was not guaranteed to succeed. It turns out that `set` *does* block, guaranteeing that the cell contains a value once `set` returns. This change updates the documentation to state that explicitly.

Happy to adjust the wording as desired.
This commit is contained in:
Joshua Nelson 2021-03-01 11:25:11 -05:00 committed by GitHub
commit 9a86a727c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -177,7 +177,10 @@ impl<T> SyncOnceCell<T> {
/// Sets the contents of this cell to `value`.
///
/// Returns `Ok(())` if the cell's value was updated.
/// May block if another thread is currently attempting to initialize the cell. The cell is
/// guaranteed to contain a value when set returns, though not necessarily the one provided.
///
/// Returns `Ok(())` if the cell's value was set by this call.
///
/// # Examples
///