Skip to content

Commit

Permalink
These impls, at least, can be avoided by deriving Ord.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuper committed Sep 14, 2013
1 parent 653ffa8 commit 6ba2cb8
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,13 +46,6 @@ impl Pos for BytePos {
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<BytePos, BytePos> for BytePos {
fn add(&self, rhs: &BytePos) -> BytePos {
BytePos(**self + **rhs)
Expand All @@ -70,13 +63,6 @@ impl Pos for CharPos {
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<CharPos,CharPos> for CharPos {
fn add(&self, rhs: &CharPos) -> CharPos {
CharPos(**self + **rhs)
Expand Down

5 comments on commit 6ba2cb8

@bors
Copy link
Contributor

@bors bors commented on 6ba2cb8 Sep 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from luqmana
at lkuper@6ba2cb8

@bors
Copy link
Contributor

@bors bors commented on 6ba2cb8 Sep 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging lkuper/rust/libsyntax-cleanup = 6ba2cb8 into auto

@bors
Copy link
Contributor

@bors bors commented on 6ba2cb8 Sep 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lkuper/rust/libsyntax-cleanup = 6ba2cb8 merged ok, testing candidate = a2231dc

@bors
Copy link
Contributor

@bors bors commented on 6ba2cb8 Sep 15, 2013

@bors
Copy link
Contributor

@bors bors commented on 6ba2cb8 Sep 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a2231dc

Please sign in to comment.