diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-17 20:56:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-17 20:56:00 +0200 |
| commit | 04d653902569b398e584692f45a2996f7437d5af (patch) | |
| tree | a4d99e21fa840a46bfa7788271b845b931b71b19 /src/liballoc | |
| parent | 2d3d0b7e934509327a757f467b89f1059a1f45c1 (diff) | |
| parent | 387ac060d2044be63786571fcf7831879d2a2bfb (diff) | |
| download | rust-04d653902569b398e584692f45a2996f7437d5af.tar.gz rust-04d653902569b398e584692f45a2996f7437d5af.zip | |
Rollup merge of #61893 - chpio:weak_ptr_eq_methods, r=rkruppe
make `Weak::ptr_eq`s into methods This makes the `Weak::ptr_eq`s associated function into methods. There's no reason for methods on `Weak`s to be associated functions, as there is no `Dered` thus no possibility of a collision. Also: methods can be called using the associated function syntax. follow up on https://github.com/rust-lang/rust/pull/55987 [Tracking issue for weak_ptr_eq](https://github.com/rust-lang/rust/issues/55981)
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 14 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 14 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 7cbb4963301..ee78839f7f0 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1515,18 +1515,18 @@ impl<T: ?Sized> Weak<T> { /// /// ``` /// #![feature(weak_ptr_eq)] - /// use std::rc::{Rc, Weak}; + /// use std::rc::Rc; /// /// let first_rc = Rc::new(5); /// let first = 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::downgrade(&third_rc); /// - /// assert!(!Weak::ptr_eq(&first, &third)); + /// assert!(!first.ptr_eq(&third)); /// ``` /// /// Comparing `Weak::new`. @@ -1537,16 +1537,16 @@ impl<T: ?Sized> Weak<T> { /// /// let first = 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::downgrade(&third_rc); - /// assert!(!Weak::ptr_eq(&first, &third)); + /// assert!(!first.ptr_eq(&third)); /// ``` #[inline] #[unstable(feature = "weak_ptr_eq", issue = "55981")] - pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() == other.ptr.as_ptr() + pub fn ptr_eq(&self, other: &Self) -> bool { + self.ptr.as_ptr() == other.ptr.as_ptr() } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2503f696bf3..6c23b3179ed 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -1349,18 +1349,18 @@ impl<T: ?Sized> Weak<T> { /// /// ``` /// #![feature(weak_ptr_eq)] - /// use std::sync::{Arc, Weak}; + /// use std::sync::Arc; /// /// let first_rc = Arc::new(5); /// let first = 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 = Arc::downgrade(&third_rc); /// - /// assert!(!Weak::ptr_eq(&first, &third)); + /// assert!(!first.ptr_eq(&third)); /// ``` /// /// Comparing `Weak::new`. @@ -1371,16 +1371,16 @@ impl<T: ?Sized> Weak<T> { /// /// let first = Weak::new(); /// let second = Weak::new(); - /// assert!(Weak::ptr_eq(&first, &second)); + /// assert!(first.ptr_eq(&second)); /// /// let third_rc = Arc::new(()); /// let third = Arc::downgrade(&third_rc); - /// assert!(!Weak::ptr_eq(&first, &third)); + /// assert!(!first.ptr_eq(&third)); /// ``` #[inline] #[unstable(feature = "weak_ptr_eq", issue = "55981")] - pub fn ptr_eq(this: &Self, other: &Self) -> bool { - this.ptr.as_ptr() == other.ptr.as_ptr() + pub fn ptr_eq(&self, other: &Self) -> bool { + self.ptr.as_ptr() == other.ptr.as_ptr() } } |
