diff options
| author | bors <bors@rust-lang.org> | 2014-11-06 08:06:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-06 08:06:50 +0000 |
| commit | e84e7a00ddec76570bbaa9afea385d544f616814 (patch) | |
| tree | 5757b1eec689ab03459c9f2518cc602284c44733 /src/liballoc | |
| parent | 0e2f9b948564708085373fc28d91b4524c821fa3 (diff) | |
| parent | 11f4baeafb83459befd0196b2b82cda7ed5ea2f1 (diff) | |
| download | rust-e84e7a00ddec76570bbaa9afea385d544f616814.tar.gz rust-e84e7a00ddec76570bbaa9afea385d544f616814.zip | |
auto merge of #18467 : japaric/rust/eq, r=alexcrichton
`eq`, `ne`, `cmp`, etc methods now require one less level of indirection when dealing with `&str`/`&[T]`
``` rust
"foo".ne(&"bar") -> "foo".ne("bar")
slice.cmp(&another_slice) -> slice.cmp(another_slice)
// slice and another_slice have type `&[T]`
```
[breaking-change]
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index de98bc63183..d1fc921ffda 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -61,12 +61,16 @@ impl<T: Clone> Clone for Box<T> { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<T:PartialEq> PartialEq for Box<T> { #[inline] fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) } #[inline] fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<T:PartialOrd> PartialOrd for Box<T> { #[inline] fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { @@ -81,14 +85,50 @@ impl<T:PartialOrd> PartialOrd for Box<T> { #[inline] fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<T: Ord> Ord for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(&**other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl<T: Eq> Eq for Box<T> {} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<Sized? T: PartialEq> PartialEq for Box<T> { + #[inline] + fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) } + #[inline] + fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<Sized? T: PartialOrd> PartialOrd for Box<T> { + #[inline] + fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { + PartialOrd::partial_cmp(&**self, &**other) + } + #[inline] + fn lt(&self, other: &Box<T>) -> bool { PartialOrd::lt(&**self, &**other) } + #[inline] + fn le(&self, other: &Box<T>) -> bool { PartialOrd::le(&**self, &**other) } + #[inline] + fn ge(&self, other: &Box<T>) -> bool { PartialOrd::ge(&**self, &**other) } + #[inline] + fn gt(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<Sized? T: Ord> Ord for Box<T> { + #[inline] + fn cmp(&self, other: &Box<T>) -> Ordering { + Ord::cmp(&**self, &**other) + } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl<Sized? T: Eq> Eq for Box<T> {} + /// Extension methods for an owning `Any` trait object. #[unstable = "post-DST and coherence changes, this will not be a trait but \ rather a direct `impl` on `Box<Any>`"] |
