Implement TotalEq and TotalOrd for Timespec
There's a test making sure that Ord works, so the order dependence shouldn't be an issue
This commit is contained in:
parent
1218f6db77
commit
8e53d61afe
@ -63,9 +63,7 @@ mod imp {
|
||||
}
|
||||
|
||||
/// A record specifying a time value in seconds and nanoseconds.
|
||||
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, Show)]
|
||||
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, Encodable, Decodable, Show)]
|
||||
pub struct Timespec { sec: i64, nsec: i32 }
|
||||
/*
|
||||
* Timespec assumes that pre-epoch Timespecs have negative sec and positive
|
||||
@ -82,13 +80,6 @@ pub fn new(sec: i64, nsec: i32) -> Timespec {
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for Timespec {
|
||||
fn lt(&self, other: &Timespec) -> bool {
|
||||
self.sec < other.sec ||
|
||||
(self.sec == other.sec && self.nsec < other.nsec)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current time as a `timespec` containing the seconds and
|
||||
* nanoseconds since 1970-01-01T00:00:00Z.
|
||||
|
Loading…
Reference in New Issue
Block a user