diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-10-30 15:33:47 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-11-05 20:13:08 -0500 |
| commit | 4c3b42271ba74ff905dd722e6480701713408d60 (patch) | |
| tree | 22c32a8ead8b11c09ca05d5aead4a6eb416bee2f /src/liballoc/boxed.rs | |
| parent | 1e5f311d1615ab4bca5b23d09dd678c2662022e6 (diff) | |
| download | rust-4c3b42271ba74ff905dd722e6480701713408d60.tar.gz rust-4c3b42271ba74ff905dd722e6480701713408d60.zip | |
DSTify Box<T> implementation of PartialEq, PartialOrd, Eq, Ord
Diffstat (limited to 'src/liballoc/boxed.rs')
| -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>`"] |
