derive Eq and Clone impls where applicable

This commit is contained in:
Andrew Paseltiner
2013-03-26 08:04:54 -04:00
parent f7f6013a62
commit f02ee42a86
11 changed files with 21 additions and 303 deletions

View File

@@ -35,10 +35,12 @@ pub trait Pos {
}
/// A byte offset
#[deriving(Eq)]
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)]
pub struct CharPos(uint);
// XXX: Lots of boilerplate in these impls, but so far my attempts to fix
@@ -49,11 +51,6 @@ impl Pos for BytePos {
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for BytePos {
fn eq(&self, other: &BytePos) -> bool { **self == **other }
fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for BytePos {
fn lt(&self, other: &BytePos) -> bool { **self < **other }
fn le(&self, other: &BytePos) -> bool { **self <= **other }
@@ -84,11 +81,6 @@ impl Pos for CharPos {
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for CharPos {
fn eq(&self, other: &CharPos) -> bool { **self == **other }
fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for CharPos {
fn lt(&self, other: &CharPos) -> bool { **self < **other }
fn le(&self, other: &CharPos) -> bool { **self <= **other }