Skip to content

Commit

Permalink
Rollup merge of rust-lang#61797 - Thomasdezeeuw:stablise-weak_ptr_eq,…
Browse files Browse the repository at this point in the history
… r=RalfJung

Stabilise weak_ptr_eq

Implemented in rust-lang#55987.

Closes rust-lang#55981.
  • Loading branch information
Centril authored Sep 14, 2019
2 parents ca3766e + 307804a commit 2286a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,8 +1832,9 @@ impl<T: ?Sized> Weak<T> {
}
}

/// Returns `true` if the two `Weak`s point to the same value (not just values
/// that compare as equal).
/// Returns `true` if the two `Weak`s point to the same value (not just
/// values that compare as equal), or if both don't point to any value
/// (because they were created with `Weak::new()`).
///
/// # Notes
///
Expand All @@ -1843,7 +1844,6 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::rc::Rc;
///
/// let first_rc = Rc::new(5);
Expand All @@ -1861,7 +1861,6 @@ impl<T: ?Sized> Weak<T> {
/// Comparing `Weak::new`.
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::rc::{Rc, Weak};
///
/// let first = Weak::new();
Expand All @@ -1873,7 +1872,7 @@ impl<T: ?Sized> Weak<T> {
/// assert!(!first.ptr_eq(&third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
#[stable(feature = "weak_ptr_eq", since = "1.39.0")]
pub fn ptr_eq(&self, other: &Self) -> bool {
self.ptr.as_ptr() == other.ptr.as_ptr()
}
Expand Down
10 changes: 4 additions & 6 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,19 +1550,18 @@ impl<T: ?Sized> Weak<T> {
}
}

/// Returns `true` if the two `Weak`s point to the same value (not just values
/// that compare as equal).
/// Returns `true` if the two `Weak`s point to the same value (not just
/// values that compare as equal), or if both don't point to any value
/// (because they were created with `Weak::new()`).
///
/// # Notes
///
/// Since this compares pointers it means that `Weak::new()` will equal each
/// other, even though they don't point to any value.
///
///
/// # Examples
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::sync::Arc;
///
/// let first_rc = Arc::new(5);
Expand All @@ -1580,7 +1579,6 @@ impl<T: ?Sized> Weak<T> {
/// Comparing `Weak::new`.
///
/// ```
/// #![feature(weak_ptr_eq)]
/// use std::sync::{Arc, Weak};
///
/// let first = Weak::new();
Expand All @@ -1592,7 +1590,7 @@ impl<T: ?Sized> Weak<T> {
/// assert!(!first.ptr_eq(&third));
/// ```
#[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")]
#[stable(feature = "weak_ptr_eq", since = "1.39.0")]
pub fn ptr_eq(&self, other: &Self) -> bool {
self.ptr.as_ptr() == other.ptr.as_ptr()
}
Expand Down

0 comments on commit 2286a45

Please sign in to comment.