diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 1c3a8e81e55..c8e40b82e0c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -30,12 +30,12 @@ pub trait Pos { } /// A byte offset -#[deriving(Clone, Eq, IterBytes)] +#[deriving(Clone, Eq, IterBytes, Ord)] pub struct BytePos(uint); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. -#[deriving(Eq,IterBytes)] +#[deriving(Eq,IterBytes, Ord)] pub struct CharPos(uint); // XXX: Lots of boilerplate in these impls, but so far my attempts to fix @@ -46,13 +46,6 @@ fn from_uint(n: uint) -> BytePos { BytePos(n) } fn to_uint(&self) -> uint { **self } } -impl cmp::Ord for BytePos { - fn lt(&self, other: &BytePos) -> bool { **self < **other } - fn le(&self, other: &BytePos) -> bool { **self <= **other } - fn ge(&self, other: &BytePos) -> bool { **self >= **other } - fn gt(&self, other: &BytePos) -> bool { **self > **other } -} - impl Add for BytePos { fn add(&self, rhs: &BytePos) -> BytePos { BytePos(**self + **rhs) @@ -70,13 +63,6 @@ fn from_uint(n: uint) -> CharPos { CharPos(n) } fn to_uint(&self) -> uint { **self } } -impl cmp::Ord for CharPos { - fn lt(&self, other: &CharPos) -> bool { **self < **other } - fn le(&self, other: &CharPos) -> bool { **self <= **other } - fn ge(&self, other: &CharPos) -> bool { **self >= **other } - fn gt(&self, other: &CharPos) -> bool { **self > **other } -} - impl Add for CharPos { fn add(&self, rhs: &CharPos) -> CharPos { CharPos(**self + **rhs)