Update for Ord changes

This commit is contained in:
Steven Fackler 2014-03-08 20:00:10 -08:00
parent 7c94c20671
commit 2064ba86ad

View File

@ -172,7 +172,7 @@ pub enum BoundType {
/// Represents a one-sided bound. /// Represents a one-sided bound.
/// ///
/// The side is determined by the `S` phantom parameter. /// The side is determined by the `S` phantom parameter.
#[deriving(Eq,Clone)] #[deriving(Clone)]
pub struct RangeBound<S, T> { pub struct RangeBound<S, T> {
/// The value of the bound /// The value of the bound
value: T, value: T,
@ -200,6 +200,12 @@ impl<S: BoundSided, T: fmt::Show> fmt::Show for RangeBound<S, T> {
} }
} }
impl<S: BoundSided, T: Eq> Eq for RangeBound<S, T> {
fn eq(&self, other: &RangeBound<S, T>) -> bool {
self.value == other.value && self.type_ == other.type_
}
}
impl<S: BoundSided, T: Ord> Ord for RangeBound<S, T> { impl<S: BoundSided, T: Ord> Ord for RangeBound<S, T> {
fn lt(&self, other: &RangeBound<S, T>) -> bool { fn lt(&self, other: &RangeBound<S, T>) -> bool {
match (BoundSided::side(None::<S>), self.type_, other.type_) { match (BoundSided::side(None::<S>), self.type_, other.type_) {
@ -229,6 +235,13 @@ impl<S: BoundSided, T: Ord> RangeBound<S, T> {
struct OptBound<'a, S, T>(Option<&'a RangeBound<S, T>>); struct OptBound<'a, S, T>(Option<&'a RangeBound<S, T>>);
impl<'a, S: BoundSided, T: Eq> Eq for OptBound<'a, S, T> {
fn eq(&self, &OptBound(ref other): &OptBound<'a, S, T>) -> bool {
let &OptBound(ref self_) = self;
self_ == other
}
}
impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> { impl<'a, S: BoundSided, T: Ord> Ord for OptBound<'a, S, T> {
fn lt(&self, other: &OptBound<'a, S, T>) -> bool { fn lt(&self, other: &OptBound<'a, S, T>) -> bool {
match (*self, *other) { match (*self, *other) {