File tree 4 files changed +19
-5
lines changed
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;
4
4
5
5
/// A value which is initialized on the first access.
6
6
///
7
+ /// For a thread-safe version of this struct, see [`std::sync::LazyLock`].
8
+ ///
9
+ /// [`std::sync::LazyLock`]: ../../std/sync/struct.LazyLock.html
10
+ ///
7
11
/// # Examples
8
12
///
9
13
/// ```
Original file line number Diff line number Diff line change @@ -4,8 +4,14 @@ use crate::mem;
4
4
5
5
/// A cell which can be written to only once.
6
6
///
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
9
15
///
10
16
/// # Examples
11
17
///
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ use crate::sync::OnceLock;
6
6
7
7
/// A value which is initialized on the first access.
8
8
///
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
10
12
///
11
13
/// # Examples
12
14
///
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ use crate::sync::Once;
7
7
8
8
/// A synchronization primitive which can be written to only once.
9
9
///
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
11
13
///
12
14
/// # Examples
13
15
///
@@ -33,7 +35,7 @@ use crate::sync::Once;
33
35
#[ unstable( feature = "once_cell" , issue = "74465" ) ]
34
36
pub struct OnceLock < T > {
35
37
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() `.
37
39
value : UnsafeCell < MaybeUninit < T > > ,
38
40
/// `PhantomData` to make sure dropck understands we're dropping T in our Drop impl.
39
41
///
You can’t perform that action at this time.
0 commit comments