replace impls with `deriving` where applicable
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index 9cf3e4d..350a1de 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -82,7 +82,6 @@
*/
-use cmp::Eq;
use cast::{forget, reinterpret_cast, transmute};
use cell::Cell;
use either::{Either, Left, Right};
@@ -103,6 +102,7 @@
)
#[doc(hidden)]
+#[deriving(Eq)]
enum State {
Empty,
Full,
@@ -110,13 +110,6 @@
Terminated
}
-impl Eq for State {
- fn eq(&self, other: &State) -> bool {
- ((*self) as uint) == ((*other) as uint)
- }
- fn ne(&self, other: &State) -> bool { !(*self).eq(other) }
-}
-
pub struct BufferHeader {
// Tracks whether this buffer needs to be freed. We can probably
// get away with restricting it to 0 or 1, if we're careful.
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index a664660..349a10b 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -72,21 +72,12 @@
* If you wish for this result's delivery to block until all linked and/or
* children tasks complete, recommend using a result future.
*/
+#[deriving(Eq)]
pub enum TaskResult {
Success,
Failure,
}
-impl Eq for TaskResult {
- fn eq(&self, other: &TaskResult) -> bool {
- match ((*self), (*other)) {
- (Success, Success) | (Failure, Failure) => true,
- (Success, _) | (Failure, _) => false
- }
- }
- fn ne(&self, other: &TaskResult) -> bool { !(*self).eq(other) }
-}
-
/// Scheduler modes
#[deriving(Eq)]
pub enum SchedMode {
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 56d5478..a69655c 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -2533,12 +2533,7 @@
impl<A:Clone> Clone for ~[A] {
#[inline]
fn clone(&self) -> ~[A] {
- let mut dolly = ~[];
- vec::reserve(&mut dolly, self.len());
- for self.each |item| {
- dolly.push(item.clone());
- }
- return dolly;
+ self.map(|item| item.clone())
}
}
diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs
index 564afea..7d20eb7 100644
--- a/src/libstd/bigint.rs
+++ b/src/libstd/bigint.rs
@@ -557,13 +557,9 @@
}
/// A Sign is a BigInt's composing element.
+#[deriving(Eq)]
pub enum Sign { Minus, Zero, Plus }
-impl Eq for Sign {
- fn eq(&self, other: &Sign) -> bool { self.cmp(other) == 0 }
- fn ne(&self, other: &Sign) -> bool { self.cmp(other) != 0 }
-}
-
impl Ord for Sign {
fn lt(&self, other: &Sign) -> bool { self.cmp(other) < 0 }
fn le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 }
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index f1f736e..a9b9b29 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -35,6 +35,7 @@
pub type List = ~[Json];
pub type Object = LinearMap<~str, Json>;
+#[deriving(Eq)]
pub struct Error {
line: uint,
col: uint,
@@ -1060,15 +1061,6 @@
fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
}
-impl Eq for Error {
- fn eq(&self, other: &Error) -> bool {
- (*self).line == other.line &&
- (*self).col == other.col &&
- (*self).msg == other.msg
- }
- fn ne(&self, other: &Error) -> bool { !(*self).eq(other) }
-}
-
trait ToJson { fn to_json(&self) -> Json; }
impl ToJson for Json {
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index ce153c1..9ac302e 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -40,6 +40,7 @@
/// A record specifying a time value in seconds and nanoseconds.
#[auto_encode]
#[auto_decode]
+#[deriving(Eq)]
pub struct Timespec { sec: i64, nsec: i32 }
/*
@@ -57,13 +58,6 @@
}
}
-impl Eq for Timespec {
- fn eq(&self, other: &Timespec) -> bool {
- self.sec == other.sec && self.nsec == other.nsec
- }
- fn ne(&self, other: &Timespec) -> bool { !self.eq(other) }
-}
-
impl Ord for Timespec {
fn lt(&self, other: &Timespec) -> bool {
self.sec < other.sec ||
@@ -117,6 +111,7 @@
#[auto_encode]
#[auto_decode]
+#[deriving(Eq)]
pub struct Tm {
tm_sec: i32, // seconds after the minute ~[0-60]
tm_min: i32, // minutes after the hour ~[0-59]
@@ -132,24 +127,6 @@
tm_nsec: i32, // nanoseconds
}
-impl Eq for Tm {
- fn eq(&self, other: &Tm) -> bool {
- self.tm_sec == (*other).tm_sec &&
- self.tm_min == (*other).tm_min &&
- self.tm_hour == (*other).tm_hour &&
- self.tm_mday == (*other).tm_mday &&
- self.tm_mon == (*other).tm_mon &&
- self.tm_year == (*other).tm_year &&
- self.tm_wday == (*other).tm_wday &&
- self.tm_yday == (*other).tm_yday &&
- self.tm_isdst == (*other).tm_isdst &&
- self.tm_gmtoff == (*other).tm_gmtoff &&
- self.tm_zone == (*other).tm_zone &&
- self.tm_nsec == (*other).tm_nsec
- }
- fn ne(&self, other: &Tm) -> bool { !self.eq(other) }
-}
-
pub fn empty_tm() -> Tm {
Tm {
tm_sec: 0_i32,