Skip to content

Commit 6ba2cb8

Browse files
committed
These impls, at least, can be avoided by deriving Ord.
1 parent 653ffa8 commit 6ba2cb8

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/libsyntax/codemap.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ pub trait Pos {
3030
}
3131

3232
/// A byte offset
33-
#[deriving(Clone, Eq, IterBytes)]
33+
#[deriving(Clone, Eq, IterBytes, Ord)]
3434
pub struct BytePos(uint);
3535
/// A character offset. Because of multibyte utf8 characters, a byte offset
3636
/// is not equivalent to a character offset. The CodeMap will convert BytePos
3737
/// values to CharPos values as necessary.
38-
#[deriving(Eq,IterBytes)]
38+
#[deriving(Eq,IterBytes, Ord)]
3939
pub struct CharPos(uint);
4040

4141
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix
@@ -46,13 +46,6 @@ impl Pos for BytePos {
4646
fn to_uint(&self) -> uint { **self }
4747
}
4848

49-
impl cmp::Ord for BytePos {
50-
fn lt(&self, other: &BytePos) -> bool { **self < **other }
51-
fn le(&self, other: &BytePos) -> bool { **self <= **other }
52-
fn ge(&self, other: &BytePos) -> bool { **self >= **other }
53-
fn gt(&self, other: &BytePos) -> bool { **self > **other }
54-
}
55-
5649
impl Add<BytePos, BytePos> for BytePos {
5750
fn add(&self, rhs: &BytePos) -> BytePos {
5851
BytePos(**self + **rhs)
@@ -70,13 +63,6 @@ impl Pos for CharPos {
7063
fn to_uint(&self) -> uint { **self }
7164
}
7265

73-
impl cmp::Ord for CharPos {
74-
fn lt(&self, other: &CharPos) -> bool { **self < **other }
75-
fn le(&self, other: &CharPos) -> bool { **self <= **other }
76-
fn ge(&self, other: &CharPos) -> bool { **self >= **other }
77-
fn gt(&self, other: &CharPos) -> bool { **self > **other }
78-
}
79-
8066
impl Add<CharPos,CharPos> for CharPos {
8167
fn add(&self, rhs: &CharPos) -> CharPos {
8268
CharPos(**self + **rhs)

0 commit comments

Comments
 (0)