Skip to content

Commit 266e957

Browse files
authored
Rollup merge of rust-lang#104528 - WaffleLapkin:lazy_lock_docfix, r=matklad
Properly link `{Once,Lazy}{Cell,Lock}` in docs See rust-lang#74465 (comment)
2 parents de29cb1 + 57e7261 commit 266e957

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

library/core/src/cell/lazy.rs

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ use crate::ops::Deref;
44

55
/// A value which is initialized on the first access.
66
///
7+
/// For a thread-safe version of this struct, see [`std::sync::LazyLock`].
8+
///
9+
/// [`std::sync::LazyLock`]: ../../std/sync/struct.LazyLock.html
10+
///
711
/// # Examples
812
///
913
/// ```

library/core/src/cell/once.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ use crate::mem;
44

55
/// A cell which can be written to only once.
66
///
7-
/// Unlike `RefCell`, a `OnceCell` only provides shared `&T` references to its value.
8-
/// Unlike `Cell`, a `OnceCell` doesn't require copying or replacing the value to access it.
7+
/// Unlike [`RefCell`], a `OnceCell` only provides shared `&T` references to its value.
8+
/// Unlike [`Cell`], a `OnceCell` doesn't require copying or replacing the value to access it.
9+
///
10+
/// For a thread-safe version of this struct, see [`std::sync::OnceLock`].
11+
///
12+
/// [`RefCell`]: crate::cell::RefCell
13+
/// [`Cell`]: crate::cell::Cell
14+
/// [`std::sync::OnceLock`]: ../../std/sync/struct.OnceLock.html
915
///
1016
/// # Examples
1117
///

library/std/src/sync/lazy_lock.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use crate::sync::OnceLock;
66

77
/// A value which is initialized on the first access.
88
///
9-
/// This type is a thread-safe `Lazy`, and can be used in statics.
9+
/// This type is a thread-safe [`LazyCell`], and can be used in statics.
10+
///
11+
/// [`LazyCell`]: crate::cell::LazyCell
1012
///
1113
/// # Examples
1214
///

library/std/src/sync/once_lock.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::sync::Once;
77

88
/// A synchronization primitive which can be written to only once.
99
///
10-
/// This type is a thread-safe `OnceCell`.
10+
/// This type is a thread-safe [`OnceCell`], and can be used in statics.
11+
///
12+
/// [`OnceCell`]: crate::cell::OnceCell
1113
///
1214
/// # Examples
1315
///
@@ -33,7 +35,7 @@ use crate::sync::Once;
3335
#[unstable(feature = "once_cell", issue = "74465")]
3436
pub struct OnceLock<T> {
3537
once: Once,
36-
// Whether or not the value is initialized is tracked by `state_and_queue`.
38+
// Whether or not the value is initialized is tracked by `once.is_completed()`.
3739
value: UnsafeCell<MaybeUninit<T>>,
3840
/// `PhantomData` to make sure dropck understands we're dropping T in our Drop impl.
3941
///

0 commit comments

Comments
 (0)