diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-09-07 12:06:02 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-09-07 12:24:48 -0700 |
| commit | feb014eb3c3aa1ccaae1df407801dffa090499fd (patch) | |
| tree | 8ffeec6945de4843f9e0d150720596327530e00f /src/libstd | |
| parent | ac1f84c153a171e641233e5d2d11404a0b520986 (diff) | |
| download | rust-feb014eb3c3aa1ccaae1df407801dffa090499fd.tar.gz rust-feb014eb3c3aa1ccaae1df407801dffa090499fd.zip | |
rustc: Add an "ne" method to the Eq trait, and implement it everywhere
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/getopts.rs | 3 | ||||
| -rw-r--r-- | src/libstd/json.rs | 6 | ||||
| -rw-r--r-- | src/libstd/list.rs | 1 | ||||
| -rw-r--r-- | src/libstd/net_url.rs | 2 | ||||
| -rw-r--r-- | src/libstd/test.rs | 1 | ||||
| -rw-r--r-- | src/libstd/time.rs | 7 |
6 files changed, 14 insertions, 6 deletions
diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 50bad1e748a..092bf5cfd78 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -124,12 +124,14 @@ impl Name : Eq { } } } + pure fn ne(&&other: Name) -> bool { !self.eq(other) } } impl Occur : Eq { pure fn eq(&&other: Occur) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: Occur) -> bool { !self.eq(other) } } /// Create an option that is required and takes an argument @@ -449,6 +451,7 @@ impl FailType : Eq { pure fn eq(&&other: FailType) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: FailType) -> bool { !self.eq(other) } } #[cfg(test)] diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 161fdf53b99..f2207f2a913 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -609,12 +609,12 @@ impl Error : Eq { self.col == other.col && self.msg == other.msg } + pure fn ne(&&other: Error) -> bool { !self.eq(other) } } impl Json : Eq { - pure fn eq(&&other: Json) -> bool { - eq(self, other) - } + pure fn eq(&&other: Json) -> bool { eq(self, other) } + pure fn ne(&&other: Json) -> bool { !self.eq(other) } } trait ToJson { fn to_json() -> Json; } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index ff4f20e7be7..71b820b4022 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -165,6 +165,7 @@ impl<T:Eq> List<T> : Eq { } } } + pure fn ne(&&other: List<T>) -> bool { !self.eq(other) } } #[cfg(test)] diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 855608a8fdf..a8872e13f0b 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -320,6 +320,7 @@ impl UserInfo : Eq { pure fn eq(&&other: UserInfo) -> bool { self.user == other.user && self.pass == other.pass } + pure fn ne(&&other: UserInfo) -> bool { !self.eq(other) } } fn query_from_str(rawquery: &str) -> Query { @@ -386,6 +387,7 @@ impl Input: Eq { (Unreserved, _) => false } } + pure fn ne(&&other: Input) -> bool { !self.eq(other) } } // returns userinfo, host, port, and unparsed part, or an error diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 8c76c316be4..db8af371cec 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -96,6 +96,7 @@ impl TestResult : Eq { pure fn eq(&&other: TestResult) -> bool { (self as uint) == (other as uint) } + pure fn ne(&&other: TestResult) -> bool { !self.eq(other) } } type ConsoleTestState = diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 86104c117b5..c012ac8fa05 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -40,6 +40,7 @@ impl Timespec : Eq { pure fn eq(&&other: Timespec) -> bool { self.sec == other.sec && self.nsec == other.nsec } + pure fn ne(&&other: Timespec) -> bool { !self.eq(other) } } /** @@ -105,6 +106,7 @@ impl Tm_ : Eq { self.tm_zone == other.tm_zone && self.tm_nsec == other.tm_nsec } + pure fn ne(&&other: Tm_) -> bool { !self.eq(other) } } enum Tm { @@ -112,9 +114,8 @@ enum Tm { } impl Tm : Eq { - pure fn eq(&&other: Tm) -> bool { - *self == *other - } + pure fn eq(&&other: Tm) -> bool { *self == *other } + pure fn ne(&&other: Tm) -> bool { *self != *other } } fn empty_tm() -> Tm { |
