diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-28 13:57:08 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-28 19:19:01 +0530 |
| commit | 6b1471967c42f46b518c43815f9133c9939fda2c (patch) | |
| tree | d2817a5e526836816b4a68a1d57ca1b3e7a2c18f | |
| parent | fcd1c3699a95eeda609d275585987828d76f2600 (diff) | |
| parent | bbd060d85a8adb0f3df26cfb84629127a9b8561a (diff) | |
| download | rust-6b1471967c42f46b518c43815f9133c9939fda2c.tar.gz rust-6b1471967c42f46b518c43815f9133c9939fda2c.zip | |
Rollup merge of #22887 - JP-Ellis:master, r=huonw
Updated the function to allow comparisons between different types since PartialOrd and PartialEq allow this.
| -rw-r--r-- | src/libcore/iter.rs | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 94cc933d844..4c9e8f47d0e 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2874,10 +2874,10 @@ pub mod order { use super::Iterator; /// Compare `a` and `b` for equality using `Eq` - pub fn equals<A, T, S>(mut a: T, mut b: S) -> bool where + pub fn equals<A, L, R>(mut a: L, mut b: R) -> bool where A: Eq, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + L: Iterator<Item=A>, + R: Iterator<Item=A>, { loop { match (a.next(), b.next()) { @@ -2889,10 +2889,10 @@ pub mod order { } /// Order `a` and `b` lexicographically using `Ord` - pub fn cmp<A, T, S>(mut a: T, mut b: S) -> cmp::Ordering where + pub fn cmp<A, L, R>(mut a: L, mut b: R) -> cmp::Ordering where A: Ord, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + L: Iterator<Item=A>, + R: Iterator<Item=A>, { loop { match (a.next(), b.next()) { @@ -2908,10 +2908,8 @@ pub mod order { } /// Order `a` and `b` lexicographically using `PartialOrd` - pub fn partial_cmp<A, T, S>(mut a: T, mut b: S) -> Option<cmp::Ordering> where - A: PartialOrd, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + pub fn partial_cmp<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> Option<cmp::Ordering> where + L::Item: PartialOrd<R::Item> { loop { match (a.next(), b.next()) { @@ -2927,10 +2925,8 @@ pub mod order { } /// Compare `a` and `b` for equality (Using partial equality, `PartialEq`) - pub fn eq<A, B, L, R>(mut a: L, mut b: R) -> bool where - A: PartialEq<B>, - L: Iterator<Item=A>, - R: Iterator<Item=B>, + pub fn eq<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialEq<R::Item>, { loop { match (a.next(), b.next()) { @@ -2942,10 +2938,8 @@ pub mod order { } /// Compare `a` and `b` for nonequality (Using partial equality, `PartialEq`) - pub fn ne<A, B, L, R>(mut a: L, mut b: R) -> bool where - A: PartialEq<B>, - L: Iterator<Item=A>, - R: Iterator<Item=B>, + pub fn ne<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialEq<R::Item>, { loop { match (a.next(), b.next()) { @@ -2957,10 +2951,8 @@ pub mod order { } /// Return `a` < `b` lexicographically (Using partial order, `PartialOrd`) - pub fn lt<A, T, S>(mut a: T, mut b: S) -> bool where - A: PartialOrd, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + pub fn lt<R: Iterator, L: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialOrd<R::Item>, { loop { match (a.next(), b.next()) { @@ -2973,10 +2965,8 @@ pub mod order { } /// Return `a` <= `b` lexicographically (Using partial order, `PartialOrd`) - pub fn le<A, T, S>(mut a: T, mut b: S) -> bool where - A: PartialOrd, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + pub fn le<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialOrd<R::Item>, { loop { match (a.next(), b.next()) { @@ -2989,10 +2979,8 @@ pub mod order { } /// Return `a` > `b` lexicographically (Using partial order, `PartialOrd`) - pub fn gt<A, T, S>(mut a: T, mut b: S) -> bool where - A: PartialOrd, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + pub fn gt<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialOrd<R::Item>, { loop { match (a.next(), b.next()) { @@ -3005,10 +2993,8 @@ pub mod order { } /// Return `a` >= `b` lexicographically (Using partial order, `PartialOrd`) - pub fn ge<A, T, S>(mut a: T, mut b: S) -> bool where - A: PartialOrd, - T: Iterator<Item=A>, - S: Iterator<Item=A>, + pub fn ge<L: Iterator, R: Iterator>(mut a: L, mut b: R) -> bool where + L::Item: PartialOrd<R::Item>, { loop { match (a.next(), b.next()) { |
