diff options
Diffstat (limited to 'src/liballoc/sync.rs')
| -rw-r--r-- | src/liballoc/sync.rs | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index d6863238cd4..e596694fb9d 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(specialization)] #![stable(feature = "rust1", since = "1.0.0")] //! Thread-safe reference-counting pointers. @@ -1289,6 +1288,37 @@ impl<T: ?Sized> Drop for Weak<T> { } #[stable(feature = "rust1", since = "1.0.0")] +trait ArcEqIdent<T: ?Sized + PartialEq> { + fn eq(&self, other: &Arc<T>) -> bool; + fn ne(&self, other: &Arc<T>) -> bool; +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T> { + #[inline] + default fn eq(&self, other: &Arc<T>) -> bool { + **self == **other + } + #[inline] + default fn ne(&self, other: &Arc<T>) -> bool { + **self != **other + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl<T: ?Sized + Eq> ArcEqIdent<T> for Arc<T> { + #[inline] + fn eq(&self, other: &Arc<T>) -> bool { + Arc::ptr_eq(self, other) || **self == **other + } + + #[inline] + fn ne(&self, other: &Arc<T>) -> bool { + !Arc::ptr_eq(self, other) && **self != **other + } +} + +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + PartialEq> PartialEq for Arc<T> { /// Equality for two `Arc`s. /// @@ -1306,8 +1336,9 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> { /// /// assert!(five == Arc::new(5)); /// ``` - default fn eq(&self, other: &Arc<T>) -> bool { - **self == **other + #[inline] + fn eq(&self, other: &Arc<T>) -> bool { + ArcEqIdent::eq(self, other) } /// Inequality for two `Arc`s. @@ -1326,23 +1357,12 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> { /// /// assert!(five != Arc::new(6)); /// ``` - default fn ne(&self, other: &Arc<T>) -> bool { - **self != **other - } -} -#[doc(hidden)] -#[stable(feature = "rust1", since = "1.0.0")] -impl<T: ?Sized + Eq> PartialEq for Arc<T> { - #[inline(always)] - fn eq(&self, other: &Arc<T>) -> bool { - Arc::ptr_eq(self, other) || **self == **other - } - - #[inline(always)] + #[inline] fn ne(&self, other: &Arc<T>) -> bool { - !Arc::ptr_eq(self, other) && **self != **other + ArcEqIdent::ne(self, other) } } + #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> { /// Partial comparison for two `Arc`s. |
