8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- // FIXME(27718): rc_counts stuff is useful internally, but was previously public
12
11
#![ allow( deprecated) ]
13
12
14
13
//! Thread-local reference-counted boxes (the `Rc<T>` type).
94
93
//! documentation for more details on interior mutability.
95
94
//!
96
95
//! ```rust
97
- //! #![feature(rc_weak)]
98
- //!
99
96
//! use std::rc::Rc;
100
97
//! use std::rc::Weak;
101
98
//! use std::cell::RefCell;
@@ -242,7 +239,7 @@ impl<T> Rc<T> {
242
239
/// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
243
240
/// ```
244
241
#[ inline]
245
- #[ unstable ( feature = "rc_unique" , reason= "needs FCP" , issue = "27718 " ) ]
242
+ #[ stable ( feature = "rc_unique" , since = "1.4.0 " ) ]
246
243
pub fn try_unwrap ( this : Self ) -> Result < T , Self > {
247
244
if Rc :: would_unwrap ( & this) {
248
245
unsafe {
@@ -263,8 +260,9 @@ impl<T> Rc<T> {
263
260
}
264
261
265
262
/// Checks if `Rc::try_unwrap` would return `Ok`.
266
- #[ unstable( feature = "rc_would_unwrap" , reason = "just added for niche usecase" ,
267
- issue = "27718" ) ]
263
+ #[ unstable( feature = "rc_would_unwrap" ,
264
+ reason = "just added for niche usecase" ,
265
+ issue = "28356" ) ]
268
266
pub fn would_unwrap ( this : & Self ) -> bool {
269
267
Rc :: strong_count ( & this) == 1
270
268
}
@@ -276,28 +274,28 @@ impl<T: ?Sized> Rc<T> {
276
274
/// # Examples
277
275
///
278
276
/// ```
279
- /// #![feature(rc_weak)]
280
- ///
281
277
/// use std::rc::Rc;
282
278
///
283
279
/// let five = Rc::new(5);
284
280
///
285
281
/// let weak_five = Rc::downgrade(&five);
286
282
/// ```
287
- #[ unstable ( feature = "rc_weak" , reason = "needs FCP" , issue = "27718 ") ]
283
+ #[ stable ( feature = "rc_weak" , since = "1.4.0 " ) ]
288
284
pub fn downgrade ( this : & Self ) -> Weak < T > {
289
285
this. inc_weak ( ) ;
290
286
Weak { _ptr : this. _ptr }
291
287
}
292
288
293
289
/// Get the number of weak references to this value.
294
290
#[ inline]
295
- #[ unstable( feature = "rc_counts" , reason = "not clearly useful" , issue = "27718" ) ]
291
+ #[ unstable( feature = "rc_counts" , reason = "not clearly useful" ,
292
+ issue = "28356" ) ]
296
293
pub fn weak_count ( this : & Self ) -> usize { this. weak ( ) - 1 }
297
294
298
295
/// Get the number of strong references to this value.
299
296
#[ inline]
300
- #[ unstable( feature = "rc_counts" , reason = "not clearly useful" , issue = "27718" ) ]
297
+ #[ unstable( feature = "rc_counts" , reason = "not clearly useful" ,
298
+ issue = "28356" ) ]
301
299
pub fn strong_count ( this : & Self ) -> usize { this. strong ( ) }
302
300
303
301
/// Returns true if there are no other `Rc` or `Weak<T>` values that share
@@ -315,7 +313,8 @@ impl<T: ?Sized> Rc<T> {
315
313
/// assert!(Rc::is_unique(&five));
316
314
/// ```
317
315
#[ inline]
318
- #[ unstable( feature = "rc_counts" , reason = "uniqueness has unclear meaning" , issue = "27718" ) ]
316
+ #[ unstable( feature = "rc_counts" , reason = "uniqueness has unclear meaning" ,
317
+ issue = "28356" ) ]
319
318
pub fn is_unique ( this : & Self ) -> bool {
320
319
Rc :: weak_count ( this) == 0 && Rc :: strong_count ( this) == 1
321
320
}
@@ -328,8 +327,6 @@ impl<T: ?Sized> Rc<T> {
328
327
/// # Examples
329
328
///
330
329
/// ```
331
- /// #![feature(rc_unique)]
332
- ///
333
330
/// use std::rc::Rc;
334
331
///
335
332
/// let mut x = Rc::new(3);
@@ -340,7 +337,7 @@ impl<T: ?Sized> Rc<T> {
340
337
/// assert!(Rc::get_mut(&mut x).is_none());
341
338
/// ```
342
339
#[ inline]
343
- #[ unstable ( feature = "rc_unique" , reason = "needs FCP" , issue = "27718 ") ]
340
+ #[ stable ( feature = "rc_unique" , since = "1.4.0 " ) ]
344
341
pub fn get_mut ( this : & mut Self ) -> Option < & mut T > {
345
342
if Rc :: is_unique ( this) {
346
343
let inner = unsafe { & mut * * this. _ptr } ;
@@ -353,7 +350,8 @@ impl<T: ?Sized> Rc<T> {
353
350
354
351
impl < T : Clone > Rc < T > {
355
352
#[ inline]
356
- #[ unstable( feature = "rc_unique" , reason = "renamed to Rc::make_mut" , issue = "27718" ) ]
353
+ #[ unstable( feature = "rc_make_unique" , reason = "renamed to Rc::make_mut" ,
354
+ issue = "27718" ) ]
357
355
#[ deprecated( since = "1.4.0" , reason = "renamed to Rc::make_mut" ) ]
358
356
pub fn make_unique ( & mut self ) -> & mut T {
359
357
Rc :: make_mut ( self )
@@ -385,7 +383,7 @@ impl<T: Clone> Rc<T> {
385
383
///
386
384
/// ```
387
385
#[ inline]
388
- #[ unstable ( feature = "rc_unique" , reason = "needs FCP" , issue = "27718 ") ]
386
+ #[ stable ( feature = "rc_unique" , since = "1.4.0 " ) ]
389
387
pub fn make_mut ( this : & mut Self ) -> & mut T {
390
388
if Rc :: strong_count ( this) != 1 {
391
389
// Gotta clone the data, there are other Rcs
@@ -693,7 +691,7 @@ impl<T> fmt::Pointer for Rc<T> {
693
691
///
694
692
/// See the [module level documentation](./index.html) for more.
695
693
#[ unsafe_no_drop_flag]
696
- #[ unstable ( feature = "rc_weak" , reason = "needs FCP" , issue = "27718 ") ]
694
+ #[ stable ( feature = "rc_weak" , since = "1.4.0 " ) ]
697
695
pub struct Weak < T : ?Sized > {
698
696
// FIXME #12808: strange names to try to avoid interfering with
699
697
// field accesses of the contained type via Deref
@@ -716,8 +714,6 @@ impl<T: ?Sized> Weak<T> {
716
714
/// # Examples
717
715
///
718
716
/// ```
719
- /// #![feature(rc_weak)]
720
- ///
721
717
/// use std::rc::Rc;
722
718
///
723
719
/// let five = Rc::new(5);
@@ -726,7 +722,7 @@ impl<T: ?Sized> Weak<T> {
726
722
///
727
723
/// let strong_five: Option<Rc<_>> = weak_five.upgrade();
728
724
/// ```
729
- #[ unstable ( feature = "rc_weak" , reason = "needs FCP" , issue = "27718 ") ]
725
+ #[ stable ( feature = "rc_weak" , since = "1.4.0 " ) ]
730
726
pub fn upgrade ( & self ) -> Option < Rc < T > > {
731
727
if self . strong ( ) == 0 {
732
728
None
@@ -746,8 +742,6 @@ impl<T: ?Sized> Drop for Weak<T> {
746
742
/// # Examples
747
743
///
748
744
/// ```
749
- /// #![feature(rc_weak)]
750
- ///
751
745
/// use std::rc::Rc;
752
746
///
753
747
/// {
@@ -783,7 +777,7 @@ impl<T: ?Sized> Drop for Weak<T> {
783
777
}
784
778
}
785
779
786
- #[ unstable ( feature = "rc_weak" , reason = "needs FCP" , issue = "27718 ") ]
780
+ #[ stable ( feature = "rc_weak" , since = "1.4.0 " ) ]
787
781
impl < T : ?Sized > Clone for Weak < T > {
788
782
789
783
/// Makes a clone of the `Weak<T>`.
@@ -793,8 +787,6 @@ impl<T: ?Sized> Clone for Weak<T> {
793
787
/// # Examples
794
788
///
795
789
/// ```
796
- /// #![feature(rc_weak)]
797
- ///
798
790
/// use std::rc::Rc;
799
791
///
800
792
/// let weak_five = Rc::downgrade(&Rc::new(5));
0 commit comments