make Weak::ptr_eqs into methods

This commit is contained in:
Thomas Heck 2019-06-16 13:57:07 +02:00
parent 374c63e0fc
commit 387ac060d2
2 changed files with 14 additions and 14 deletions

View file

@ -1515,18 +1515,18 @@ impl<T: ?Sized> Weak<T> {
/// ///
/// ``` /// ```
/// #![feature(weak_ptr_eq)] /// #![feature(weak_ptr_eq)]
/// use std::rc::{Rc, Weak}; /// use std::rc::Rc;
/// ///
/// let first_rc = Rc::new(5); /// let first_rc = Rc::new(5);
/// let first = Rc::downgrade(&first_rc); /// let first = Rc::downgrade(&first_rc);
/// let second = Rc::downgrade(&first_rc); /// let second = Rc::downgrade(&first_rc);
/// ///
/// assert!(Weak::ptr_eq(&first, &second)); /// assert!(first.ptr_eq(&second));
/// ///
/// let third_rc = Rc::new(5); /// let third_rc = Rc::new(5);
/// let third = Rc::downgrade(&third_rc); /// let third = Rc::downgrade(&third_rc);
/// ///
/// assert!(!Weak::ptr_eq(&first, &third)); /// assert!(!first.ptr_eq(&third));
/// ``` /// ```
/// ///
/// Comparing `Weak::new`. /// Comparing `Weak::new`.
@ -1537,16 +1537,16 @@ impl<T: ?Sized> Weak<T> {
/// ///
/// let first = Weak::new(); /// let first = Weak::new();
/// let second = Weak::new(); /// let second = Weak::new();
/// assert!(Weak::ptr_eq(&first, &second)); /// assert!(first.ptr_eq(&second));
/// ///
/// let third_rc = Rc::new(()); /// let third_rc = Rc::new(());
/// let third = Rc::downgrade(&third_rc); /// let third = Rc::downgrade(&third_rc);
/// assert!(!Weak::ptr_eq(&first, &third)); /// assert!(!first.ptr_eq(&third));
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")] #[unstable(feature = "weak_ptr_eq", issue = "55981")]
pub fn ptr_eq(this: &Self, other: &Self) -> bool { pub fn ptr_eq(&self, other: &Self) -> bool {
this.ptr.as_ptr() == other.ptr.as_ptr() self.ptr.as_ptr() == other.ptr.as_ptr()
} }
} }

View file

@ -1349,18 +1349,18 @@ impl<T: ?Sized> Weak<T> {
/// ///
/// ``` /// ```
/// #![feature(weak_ptr_eq)] /// #![feature(weak_ptr_eq)]
/// use std::sync::{Arc, Weak}; /// use std::sync::Arc;
/// ///
/// let first_rc = Arc::new(5); /// let first_rc = Arc::new(5);
/// let first = Arc::downgrade(&first_rc); /// let first = Arc::downgrade(&first_rc);
/// let second = Arc::downgrade(&first_rc); /// let second = Arc::downgrade(&first_rc);
/// ///
/// assert!(Weak::ptr_eq(&first, &second)); /// assert!(first.ptr_eq(&second));
/// ///
/// let third_rc = Arc::new(5); /// let third_rc = Arc::new(5);
/// let third = Arc::downgrade(&third_rc); /// let third = Arc::downgrade(&third_rc);
/// ///
/// assert!(!Weak::ptr_eq(&first, &third)); /// assert!(!first.ptr_eq(&third));
/// ``` /// ```
/// ///
/// Comparing `Weak::new`. /// Comparing `Weak::new`.
@ -1371,16 +1371,16 @@ impl<T: ?Sized> Weak<T> {
/// ///
/// let first = Weak::new(); /// let first = Weak::new();
/// let second = Weak::new(); /// let second = Weak::new();
/// assert!(Weak::ptr_eq(&first, &second)); /// assert!(first.ptr_eq(&second));
/// ///
/// let third_rc = Arc::new(()); /// let third_rc = Arc::new(());
/// let third = Arc::downgrade(&third_rc); /// let third = Arc::downgrade(&third_rc);
/// assert!(!Weak::ptr_eq(&first, &third)); /// assert!(!first.ptr_eq(&third));
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "weak_ptr_eq", issue = "55981")] #[unstable(feature = "weak_ptr_eq", issue = "55981")]
pub fn ptr_eq(this: &Self, other: &Self) -> bool { pub fn ptr_eq(&self, other: &Self) -> bool {
this.ptr.as_ptr() == other.ptr.as_ptr() self.ptr.as_ptr() == other.ptr.as_ptr()
} }
} }