@@ -29,7 +29,7 @@ use crate::mem;
29
29
/// assert_eq!(value, "Hello, World!");
30
30
/// assert!(cell.get().is_some());
31
31
/// ```
32
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
32
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
33
33
pub struct OnceCell < T > {
34
34
// Invariant: written to at most once.
35
35
inner : UnsafeCell < Option < T > > ,
@@ -39,8 +39,8 @@ impl<T> OnceCell<T> {
39
39
/// Creates a new empty cell.
40
40
#[ inline]
41
41
#[ must_use]
42
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
43
- #[ rustc_const_stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
42
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
43
+ #[ rustc_const_stable( feature = "once_cell" , since = "1.70.0 " ) ]
44
44
pub const fn new ( ) -> OnceCell < T > {
45
45
OnceCell { inner : UnsafeCell :: new ( None ) }
46
46
}
@@ -49,7 +49,7 @@ impl<T> OnceCell<T> {
49
49
///
50
50
/// Returns `None` if the cell is empty.
51
51
#[ inline]
52
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
52
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
53
53
pub fn get ( & self ) -> Option < & T > {
54
54
// SAFETY: Safe due to `inner`'s invariant
55
55
unsafe { & * self . inner . get ( ) } . as_ref ( )
@@ -59,7 +59,7 @@ impl<T> OnceCell<T> {
59
59
///
60
60
/// Returns `None` if the cell is empty.
61
61
#[ inline]
62
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
62
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
63
63
pub fn get_mut ( & mut self ) -> Option < & mut T > {
64
64
self . inner . get_mut ( ) . as_mut ( )
65
65
}
@@ -85,7 +85,7 @@ impl<T> OnceCell<T> {
85
85
/// assert!(cell.get().is_some());
86
86
/// ```
87
87
#[ inline]
88
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
88
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
89
89
pub fn set ( & self , value : T ) -> Result < ( ) , T > {
90
90
// SAFETY: Safe because we cannot have overlapping mutable borrows
91
91
let slot = unsafe { & * self . inner . get ( ) } ;
@@ -125,7 +125,7 @@ impl<T> OnceCell<T> {
125
125
/// assert_eq!(value, &92);
126
126
/// ```
127
127
#[ inline]
128
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
128
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
129
129
pub fn get_or_init < F > ( & self , f : F ) -> & T
130
130
where
131
131
F : FnOnce ( ) -> T ,
@@ -206,7 +206,7 @@ impl<T> OnceCell<T> {
206
206
/// assert_eq!(cell.into_inner(), Some("hello".to_string()));
207
207
/// ```
208
208
#[ inline]
209
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
209
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
210
210
pub fn into_inner ( self ) -> Option < T > {
211
211
// Because `into_inner` takes `self` by value, the compiler statically verifies
212
212
// that it is not currently borrowed. So it is safe to move out `Option<T>`.
@@ -233,21 +233,21 @@ impl<T> OnceCell<T> {
233
233
/// assert_eq!(cell.get(), None);
234
234
/// ```
235
235
#[ inline]
236
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
236
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
237
237
pub fn take ( & mut self ) -> Option < T > {
238
238
mem:: take ( self ) . into_inner ( )
239
239
}
240
240
}
241
241
242
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
242
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
243
243
impl < T > Default for OnceCell < T > {
244
244
#[ inline]
245
245
fn default ( ) -> Self {
246
246
Self :: new ( )
247
247
}
248
248
}
249
249
250
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
250
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
251
251
impl < T : fmt:: Debug > fmt:: Debug for OnceCell < T > {
252
252
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
253
253
match self . get ( ) {
@@ -257,7 +257,7 @@ impl<T: fmt::Debug> fmt::Debug for OnceCell<T> {
257
257
}
258
258
}
259
259
260
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
260
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
261
261
impl < T : Clone > Clone for OnceCell < T > {
262
262
#[ inline]
263
263
fn clone ( & self ) -> OnceCell < T > {
@@ -272,18 +272,18 @@ impl<T: Clone> Clone for OnceCell<T> {
272
272
}
273
273
}
274
274
275
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
275
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
276
276
impl < T : PartialEq > PartialEq for OnceCell < T > {
277
277
#[ inline]
278
278
fn eq ( & self , other : & Self ) -> bool {
279
279
self . get ( ) == other. get ( )
280
280
}
281
281
}
282
282
283
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
283
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
284
284
impl < T : Eq > Eq for OnceCell < T > { }
285
285
286
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
286
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
287
287
#[ rustc_const_unstable( feature = "const_convert" , issue = "88674" ) ]
288
288
impl < T > const From < T > for OnceCell < T > {
289
289
/// Creates a new `OnceCell<T>` which already contains the given `value`.
@@ -294,5 +294,5 @@ impl<T> const From<T> for OnceCell<T> {
294
294
}
295
295
296
296
// Just like for `Cell<T>` this isn't needed, but results in nicer error messages.
297
- #[ stable( feature = "once_cell" , since = "CURRENT_RUSTC_VERSION " ) ]
297
+ #[ stable( feature = "once_cell" , since = "1.70.0 " ) ]
298
298
impl < T > !Sync for OnceCell < T > { }
0 commit comments