Skip to content

Commit b02ed1e

Browse files
committed
Stabilize:
- `std::rc::Rc::{strong_count, weak_count}` - `std::sync::Arc::{strong_count, weak_count}` Deprecate: - `std::rc::Rc::{would_unwrap, is_unique}`
1 parent 65b144c commit b02ed1e

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/liballoc/arc.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ impl<T: ?Sized> Arc<T> {
392392
/// # Examples
393393
///
394394
/// ```
395-
/// #![feature(arc_counts)]
396-
///
397395
/// use std::sync::Arc;
398396
///
399397
/// let five = Arc::new(5);
@@ -404,8 +402,7 @@ impl<T: ?Sized> Arc<T> {
404402
/// assert_eq!(1, Arc::weak_count(&five));
405403
/// ```
406404
#[inline]
407-
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
408-
issue = "28356")]
405+
#[stable(feature = "arc_counts", since = "1.15.0")]
409406
pub fn weak_count(this: &Self) -> usize {
410407
this.inner().weak.load(SeqCst) - 1
411408
}
@@ -421,8 +418,6 @@ impl<T: ?Sized> Arc<T> {
421418
/// # Examples
422419
///
423420
/// ```
424-
/// #![feature(arc_counts)]
425-
///
426421
/// use std::sync::Arc;
427422
///
428423
/// let five = Arc::new(5);
@@ -433,8 +428,7 @@ impl<T: ?Sized> Arc<T> {
433428
/// assert_eq!(2, Arc::strong_count(&five));
434429
/// ```
435430
#[inline]
436-
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
437-
issue = "28356")]
431+
#[stable(feature = "arc_counts", since = "1.15.0")]
438432
pub fn strong_count(this: &Self) -> usize {
439433
this.inner().strong.load(SeqCst)
440434
}

src/liballoc/rc.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ impl<T> Rc<T> {
363363
#[unstable(feature = "rc_would_unwrap",
364364
reason = "just added for niche usecase",
365365
issue = "28356")]
366+
#[rustc_deprecated(since = "1.15.0", reason = "too niche; use `strong_count` instead")]
366367
pub fn would_unwrap(this: &Self) -> bool {
367368
Rc::strong_count(&this) == 1
368369
}
@@ -482,8 +483,6 @@ impl<T: ?Sized> Rc<T> {
482483
/// # Examples
483484
///
484485
/// ```
485-
/// #![feature(rc_counts)]
486-
///
487486
/// use std::rc::Rc;
488487
///
489488
/// let five = Rc::new(5);
@@ -492,8 +491,7 @@ impl<T: ?Sized> Rc<T> {
492491
/// assert_eq!(1, Rc::weak_count(&five));
493492
/// ```
494493
#[inline]
495-
#[unstable(feature = "rc_counts", reason = "not clearly useful",
496-
issue = "28356")]
494+
#[stable(feature = "rc_counts", since = "1.15.0")]
497495
pub fn weak_count(this: &Self) -> usize {
498496
this.weak() - 1
499497
}
@@ -503,8 +501,6 @@ impl<T: ?Sized> Rc<T> {
503501
/// # Examples
504502
///
505503
/// ```
506-
/// #![feature(rc_counts)]
507-
///
508504
/// use std::rc::Rc;
509505
///
510506
/// let five = Rc::new(5);
@@ -513,8 +509,7 @@ impl<T: ?Sized> Rc<T> {
513509
/// assert_eq!(2, Rc::strong_count(&five));
514510
/// ```
515511
#[inline]
516-
#[unstable(feature = "rc_counts", reason = "not clearly useful",
517-
issue = "28356")]
512+
#[stable(feature = "rc_counts", since = "1.15.0")]
518513
pub fn strong_count(this: &Self) -> usize {
519514
this.strong()
520515
}
@@ -538,6 +533,8 @@ impl<T: ?Sized> Rc<T> {
538533
#[inline]
539534
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning",
540535
issue = "28356")]
536+
#[rustc_deprecated(since = "1.15.0",
537+
reason = "too niche; use `strong_count` and `weak_count` instead")]
541538
pub fn is_unique(this: &Self) -> bool {
542539
Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1
543540
}

0 commit comments

Comments
 (0)