@@ -26,20 +26,20 @@ use crate::ops::Deref;
26
26
/// assert_eq!(value, "Hello, World!");
27
27
/// assert!(cell.get().is_some());
28
28
/// ```
29
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
29
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
30
30
pub struct OnceCell < T > {
31
31
// Invariant: written to at most once.
32
32
inner : UnsafeCell < Option < T > > ,
33
33
}
34
34
35
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
35
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
36
36
impl < T > Default for OnceCell < T > {
37
37
fn default ( ) -> Self {
38
38
Self :: new ( )
39
39
}
40
40
}
41
41
42
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
42
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
43
43
impl < T : fmt:: Debug > fmt:: Debug for OnceCell < T > {
44
44
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
45
45
match self . get ( ) {
@@ -49,7 +49,7 @@ impl<T: fmt::Debug> fmt::Debug for OnceCell<T> {
49
49
}
50
50
}
51
51
52
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
52
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
53
53
impl < T : Clone > Clone for OnceCell < T > {
54
54
fn clone ( & self ) -> OnceCell < T > {
55
55
let res = OnceCell :: new ( ) ;
@@ -63,17 +63,17 @@ impl<T: Clone> Clone for OnceCell<T> {
63
63
}
64
64
}
65
65
66
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
66
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
67
67
impl < T : PartialEq > PartialEq for OnceCell < T > {
68
68
fn eq ( & self , other : & Self ) -> bool {
69
69
self . get ( ) == other. get ( )
70
70
}
71
71
}
72
72
73
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
73
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
74
74
impl < T : Eq > Eq for OnceCell < T > { }
75
75
76
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
76
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
77
77
impl < T > From < T > for OnceCell < T > {
78
78
fn from ( value : T ) -> Self {
79
79
OnceCell { inner : UnsafeCell :: new ( Some ( value) ) }
@@ -82,15 +82,15 @@ impl<T> From<T> for OnceCell<T> {
82
82
83
83
impl < T > OnceCell < T > {
84
84
/// Creates a new empty cell.
85
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
85
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
86
86
pub const fn new ( ) -> OnceCell < T > {
87
87
OnceCell { inner : UnsafeCell :: new ( None ) }
88
88
}
89
89
90
90
/// Gets the reference to the underlying value.
91
91
///
92
92
/// Returns `None` if the cell is empty.
93
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
93
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
94
94
pub fn get ( & self ) -> Option < & T > {
95
95
// Safety: Safe due to `inner`'s invariant
96
96
unsafe { & * self . inner . get ( ) } . as_ref ( )
@@ -99,7 +99,7 @@ impl<T> OnceCell<T> {
99
99
/// Gets the mutable reference to the underlying value.
100
100
///
101
101
/// Returns `None` if the cell is empty.
102
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
102
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
103
103
pub fn get_mut ( & mut self ) -> Option < & mut T > {
104
104
// Safety: Safe because we have unique access
105
105
unsafe { & mut * self . inner . get ( ) } . as_mut ( )
@@ -127,7 +127,7 @@ impl<T> OnceCell<T> {
127
127
///
128
128
/// assert!(cell.get().is_some());
129
129
/// ```
130
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
130
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
131
131
pub fn set ( & self , value : T ) -> Result < ( ) , T > {
132
132
// Safety: Safe because we cannot have overlapping mutable borrows
133
133
let slot = unsafe { & * self . inner . get ( ) } ;
@@ -168,7 +168,7 @@ impl<T> OnceCell<T> {
168
168
/// let value = cell.get_or_init(|| unreachable!());
169
169
/// assert_eq!(value, &92);
170
170
/// ```
171
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
171
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
172
172
pub fn get_or_init < F > ( & self , f : F ) -> & T
173
173
where
174
174
F : FnOnce ( ) -> T ,
@@ -206,7 +206,7 @@ impl<T> OnceCell<T> {
206
206
/// assert_eq!(value, Ok(&92));
207
207
/// assert_eq!(cell.get(), Some(&92))
208
208
/// ```
209
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
209
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
210
210
pub fn get_or_try_init < F , E > ( & self , f : F ) -> Result < & T , E >
211
211
where
212
212
F : FnOnce ( ) -> Result < T , E > ,
@@ -241,7 +241,7 @@ impl<T> OnceCell<T> {
241
241
/// cell.set("hello".to_string()).unwrap();
242
242
/// assert_eq!(cell.into_inner(), Some("hello".to_string()));
243
243
/// ```
244
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
244
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
245
245
pub fn into_inner ( self ) -> Option < T > {
246
246
// Because `into_inner` takes `self` by value, the compiler statically verifies
247
247
// that it is not currently borrowed. So it is safe to move out `Option<T>`.
@@ -269,7 +269,7 @@ impl<T> OnceCell<T> {
269
269
/// assert_eq!(cell.take(), Some("hello".to_string()));
270
270
/// assert_eq!(cell.get(), None);
271
271
/// ```
272
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
272
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
273
273
pub fn take ( & mut self ) -> Option < T > {
274
274
mem:: take ( self ) . into_inner ( )
275
275
}
@@ -298,13 +298,13 @@ impl<T> OnceCell<T> {
298
298
/// // 92
299
299
/// // 92
300
300
/// ```
301
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
301
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
302
302
pub struct Lazy < T , F = fn ( ) -> T > {
303
303
cell : OnceCell < T > ,
304
304
init : Cell < Option < F > > ,
305
305
}
306
306
307
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
307
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
308
308
impl < T : fmt:: Debug , F > fmt:: Debug for Lazy < T , F > {
309
309
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
310
310
f. debug_struct ( "Lazy" ) . field ( "cell" , & self . cell ) . field ( "init" , & ".." ) . finish ( )
@@ -329,7 +329,7 @@ impl<T, F> Lazy<T, F> {
329
329
/// assert_eq!(&*lazy, "HELLO, WORLD!");
330
330
/// # }
331
331
/// ```
332
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
332
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
333
333
pub const fn new ( init : F ) -> Lazy < T , F > {
334
334
Lazy { cell : OnceCell :: new ( ) , init : Cell :: new ( Some ( init) ) }
335
335
}
@@ -353,7 +353,7 @@ impl<T, F: FnOnce() -> T> Lazy<T, F> {
353
353
/// assert_eq!(Lazy::force(&lazy), &92);
354
354
/// assert_eq!(&*lazy, &92);
355
355
/// ```
356
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
356
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
357
357
pub fn force ( this : & Lazy < T , F > ) -> & T {
358
358
this. cell . get_or_init ( || match this. init . take ( ) {
359
359
Some ( f) => f ( ) ,
@@ -362,15 +362,15 @@ impl<T, F: FnOnce() -> T> Lazy<T, F> {
362
362
}
363
363
}
364
364
365
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
365
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
366
366
impl < T , F : FnOnce ( ) -> T > Deref for Lazy < T , F > {
367
367
type Target = T ;
368
368
fn deref ( & self ) -> & T {
369
369
Lazy :: force ( self )
370
370
}
371
371
}
372
372
373
- #[ unstable( feature = "once_cell" , issue = "68198 " ) ]
373
+ #[ unstable( feature = "once_cell" , issue = "74465 " ) ]
374
374
impl < T : Default > Default for Lazy < T > {
375
375
/// Creates a new lazy value using `Default` as the initializing function.
376
376
fn default ( ) -> Lazy < T > {
0 commit comments