Skip to content

Commit 8e53d61

Browse files
committed
Implement TotalEq and TotalOrd for Timespec
There's a test making sure that Ord works, so the order dependence shouldn't be an issue
1 parent 1218f6d commit 8e53d61

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/libtime/lib.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ mod imp {
6363
}
6464

6565
/// A record specifying a time value in seconds and nanoseconds.
66-
67-
68-
#[deriving(Clone, Eq, Encodable, Decodable, Show)]
66+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Encodable, Decodable, Show)]
6967
pub struct Timespec { sec: i64, nsec: i32 }
7068
/*
7169
* Timespec assumes that pre-epoch Timespecs have negative sec and positive
@@ -82,13 +80,6 @@ impl Timespec {
8280
}
8381
}
8482

85-
impl Ord for Timespec {
86-
fn lt(&self, other: &Timespec) -> bool {
87-
self.sec < other.sec ||
88-
(self.sec == other.sec && self.nsec < other.nsec)
89-
}
90-
}
91-
9283
/**
9384
* Returns the current time as a `timespec` containing the seconds and
9485
* nanoseconds since 1970-01-01T00:00:00Z.

0 commit comments

Comments
 (0)