[stdlib] [SR-4005] Allow heterogenous comparisons in elementsEqual (#8045)

* [SR-4005] Allow heterogenous comparisons in elementsEqual

When a user is supplying a predicate to compare the type equivalence
isn’t required

* elementsEqualWithPredicate tests

Compares a string of a number with an integer value by using the
elementsEqualPredicate closure

* Update test expectations to use new sequence element types

* Update hardcoded test to reference sequence
This commit is contained in:
Christian Bieniak
2017-11-30 12:06:38 +11:00
committed by Ben Cohen
parent 6c4ed9c3c2
commit ec0d53f96f
4 changed files with 58 additions and 3 deletions

View File

@@ -338,12 +338,14 @@ ${equivalenceExplanation}
public func elementsEqual<OtherSequence>(
_ other: OtherSequence${"," if preds else ""}
% if preds:
by areEquivalent: (Element, Element) throws -> Bool
by areEquivalent: (Element, OtherSequence.Element) throws -> Bool
% end
) ${rethrows_}-> Bool
where
OtherSequence: Sequence,
OtherSequence: Sequence${" {" if preds else ","}
% if not preds:
OtherSequence.Element == Element {
% end
var iter1 = self.makeIterator()
var iter2 = other.makeIterator()