mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
committed by
Ben Cohen
parent
6c4ed9c3c2
commit
ec0d53f96f
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user