From 4c3b42271ba74ff905dd722e6480701713408d60 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 30 Oct 2014 15:33:47 -0500 Subject: DSTify Box implementation of PartialEq, PartialOrd, Eq, Ord --- src/liballoc/boxed.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/liballoc/boxed.rs') 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 Clone for Box { } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl PartialEq for Box { #[inline] fn eq(&self, other: &Box) -> bool { *(*self) == *(*other) } #[inline] fn ne(&self, other: &Box) -> bool { *(*self) != *(*other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl PartialOrd for Box { #[inline] fn partial_cmp(&self, other: &Box) -> Option { @@ -81,14 +85,50 @@ impl PartialOrd for Box { #[inline] fn gt(&self, other: &Box) -> bool { *(*self) > *(*other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl Ord for Box { #[inline] fn cmp(&self, other: &Box) -> Ordering { (**self).cmp(&**other) } } +// NOTE(stage0): remove impl after a snapshot +#[cfg(stage0)] impl Eq for Box {} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl PartialEq for Box { + #[inline] + fn eq(&self, other: &Box) -> bool { PartialEq::eq(&**self, &**other) } + #[inline] + fn ne(&self, other: &Box) -> bool { PartialEq::ne(&**self, &**other) } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl PartialOrd for Box { + #[inline] + fn partial_cmp(&self, other: &Box) -> Option { + PartialOrd::partial_cmp(&**self, &**other) + } + #[inline] + fn lt(&self, other: &Box) -> bool { PartialOrd::lt(&**self, &**other) } + #[inline] + fn le(&self, other: &Box) -> bool { PartialOrd::le(&**self, &**other) } + #[inline] + fn ge(&self, other: &Box) -> bool { PartialOrd::ge(&**self, &**other) } + #[inline] + fn gt(&self, other: &Box) -> bool { PartialOrd::gt(&**self, &**other) } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl Ord for Box { + #[inline] + fn cmp(&self, other: &Box) -> Ordering { + Ord::cmp(&**self, &**other) + } +} +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +impl Eq for Box {} + /// 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`"] -- cgit 1.4.1-3-g733a5