Deprecate Equiv

This commit is contained in:
Jorge Aparicio
2014-11-26 23:50:12 -05:00
parent 09707d70a4
commit 5cfac94201
10 changed files with 20 additions and 5 deletions

View File

@@ -563,6 +563,7 @@ impl<'a> Ord for MaybeOwned<'a> {
} }
} }
#[allow(deprecated)]
#[deprecated = "use std::str::CowString"] #[deprecated = "use std::str::CowString"]
impl<'a, S: Str> Equiv<S> for MaybeOwned<'a> { impl<'a, S: Str> Equiv<S> for MaybeOwned<'a> {
#[inline] #[inline]

View File

@@ -822,7 +822,8 @@ impl<H: hash::Writer> hash::Hash<H> for String {
} }
} }
#[experimental = "waiting on Equiv stabilization"] #[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<'a, S: Str> Equiv<S> for String { impl<'a, S: Str> Equiv<S> for String {
#[inline] #[inline]
fn equiv(&self, other: &S) -> bool { fn equiv(&self, other: &S) -> bool {

View File

@@ -609,7 +609,8 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
#[unstable = "waiting on Eq stability"] #[unstable = "waiting on Eq stability"]
impl<T: Eq> Eq for Vec<T> {} impl<T: Eq> Eq for Vec<T> {}
#[experimental] #[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for Vec<T> { impl<T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for Vec<T> {
#[inline] #[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }

View File

@@ -240,7 +240,7 @@ pub trait PartialOrd<Sized? Rhs = Self> for Sized?: PartialEq<Rhs> {
/// of different types. The most common use case for this relation is /// of different types. The most common use case for this relation is
/// container types; e.g. it is often desirable to be able to use `&str` /// container types; e.g. it is often desirable to be able to use `&str`
/// values to look up entries in a container with `String` keys. /// values to look up entries in a container with `String` keys.
#[experimental = "Better solutions may be discovered."] #[deprecated = "Use overloaded core::cmp::PartialEq"]
pub trait Equiv<Sized? T> for Sized? { pub trait Equiv<Sized? T> for Sized? {
/// Implement this function to decide equivalent values. /// Implement this function to decide equivalent values.
fn equiv(&self, other: &T) -> bool; fn equiv(&self, other: &T) -> bool;

View File

@@ -321,12 +321,16 @@ impl<T> PartialEq for *mut T {
impl<T> Eq for *mut T {} impl<T> Eq for *mut T {}
// Equivalence for pointers // Equivalence for pointers
#[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<T> Equiv<*mut T> for *const T { impl<T> Equiv<*mut T> for *const T {
fn equiv(&self, other: &*mut T) -> bool { fn equiv(&self, other: &*mut T) -> bool {
self.to_uint() == other.to_uint() self.to_uint() == other.to_uint()
} }
} }
#[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<T> Equiv<*const T> for *mut T { impl<T> Equiv<*const T> for *mut T {
fn equiv(&self, other: &*const T) -> bool { fn equiv(&self, other: &*const T) -> bool {
self.to_uint() == other.to_uint() self.to_uint() == other.to_uint()

View File

@@ -1816,13 +1816,15 @@ impl<A, B> PartialEq<[B]> for [A] where A: PartialEq<B> {
#[unstable = "waiting for DST"] #[unstable = "waiting for DST"]
impl<T: Eq> Eq for [T] {} impl<T: Eq> Eq for [T] {}
#[unstable = "waiting for DST"] #[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for [T] { impl<T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for [T] {
#[inline] #[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
} }
#[unstable = "waiting for DST"] #[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<'a,T:PartialEq, Sized? V: AsSlice<T>> Equiv<V> for &'a mut [T] { impl<'a,T:PartialEq, Sized? V: AsSlice<T>> Equiv<V> for &'a mut [T] {
#[inline] #[inline]
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }

View File

@@ -1248,6 +1248,8 @@ pub mod traits {
} }
} }
#[allow(deprecated)]
#[deprecated = "Use overloaded `core::cmp::PartialEq`"]
impl<S: Str> Equiv<S> for str { impl<S: Str> Equiv<S> for str {
#[inline] #[inline]
fn equiv(&self, other: &S) -> bool { eq_slice(self, other.as_slice()) } fn equiv(&self, other: &S) -> bool { eq_slice(self, other.as_slice()) }

View File

@@ -96,6 +96,7 @@ impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
} }
} }
#[allow(deprecated)]
impl<'a, T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for MaybeOwnedVector<'a, T> { impl<'a, T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
fn equiv(&self, other: &V) -> bool { fn equiv(&self, other: &V) -> bool {
self.as_slice() == other.as_slice() self.as_slice() == other.as_slice()

View File

@@ -425,12 +425,14 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
table::make_hash(&self.hasher, x) table::make_hash(&self.hasher, x)
} }
#[allow(deprecated)]
fn search_equiv<'a, Sized? Q: Hash<S> + Equiv<K>>(&'a self, q: &Q) fn search_equiv<'a, Sized? Q: Hash<S> + Equiv<K>>(&'a self, q: &Q)
-> Option<FullBucketImm<'a, K, V>> { -> Option<FullBucketImm<'a, K, V>> {
let hash = self.make_hash(q); let hash = self.make_hash(q);
search_hashed(&self.table, &hash, |k| q.equiv(k)).into_option() search_hashed(&self.table, &hash, |k| q.equiv(k)).into_option()
} }
#[allow(deprecated)]
fn search_equiv_mut<'a, Sized? Q: Hash<S> + Equiv<K>>(&'a mut self, q: &Q) fn search_equiv_mut<'a, Sized? Q: Hash<S> + Equiv<K>>(&'a mut self, q: &Q)
-> Option<FullBucketMut<'a, K, V>> { -> Option<FullBucketMut<'a, K, V>> {
let hash = self.make_hash(q); let hash = self.make_hash(q);

View File

@@ -623,6 +623,7 @@ impl fmt::Show for InternedString {
} }
} }
#[allow(deprecated)]
impl<'a> Equiv<&'a str> for InternedString { impl<'a> Equiv<&'a str> for InternedString {
fn equiv(&self, other: & &'a str) -> bool { fn equiv(&self, other: & &'a str) -> bool {
(*other) == self.string.as_slice() (*other) == self.string.as_slice()