File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff 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/// ```
Original file line number Diff line number Diff 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///
Original file line number Diff line number Diff 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///
Original file line number Diff line number Diff 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" ) ]
3436pub 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 ///
You can’t perform that action at this time.
0 commit comments