From 6ba2cb88a6866f96f26f2906654f03f97dd8e53b Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Sat, 14 Sep 2013 19:37:39 -0400 Subject: [PATCH] These impls, at least, can be avoided by deriving Ord. --- src/libsyntax/codemap.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) 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)