File tree 2 files changed +10
-17
lines changed
2 files changed +10
-17
lines changed Original file line number Diff line number Diff line change 1
1
2
2
@_spi ( Internal)
3
3
public func areEqual< each Element : Equatable > ( _ lhs: ( repeat each Element ) , _ rhs: ( repeat each Element ) ) -> Bool {
4
-
5
- // https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
6
-
7
- func isEqual< T: Equatable > ( _ left: T , _ right: T ) throws {
8
- if left == right {
9
- return
10
- }
11
-
12
- throw NotEqual ( )
4
+
5
+ for (left, right) in repeat ( each lhs, each rhs) {
6
+ guard left == right else { return false }
13
7
}
14
-
15
- do {
16
- repeat try isEqual ( each lhs, each rhs)
17
- } catch {
18
- return false
19
- }
20
-
21
8
return true
9
+
22
10
}
23
11
Original file line number Diff line number Diff line change @@ -42,7 +42,12 @@ extension TypedComparator {
42
42
*/
43
43
public static func equality< each T : Equatable > ( ) -> Self where Self == AnyEqualityComparator < ( repeat each T ) > {
44
44
return . init { a, b in
45
- areEqual ( ( repeat each a) , ( repeat each b) )
45
+
46
+ for (left, right) in repeat ( each a, each b) {
47
+ guard left == right else { return false }
48
+ }
49
+ return true
50
+
46
51
}
47
52
}
48
53
You can’t perform that action at this time.
0 commit comments