Skip to content

Commit

Permalink
Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Oct 21, 2024
1 parent ea8f1e5 commit e8009ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
20 changes: 4 additions & 16 deletions Sources/VergeComparator/PackedCompare.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@

@_spi(Internal)
public func areEqual<each Element: Equatable>(_ lhs: (repeat each Element), _ rhs: (repeat each Element)) -> Bool {

// https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md

func isEqual<T: Equatable>(_ left: T, _ right: T) throws {
if left == right {
return
}

throw NotEqual()

for (left, right) in repeat (each lhs, each rhs) {

Check failure on line 5 in Sources/VergeComparator/PackedCompare.swift

View workflow job for this annotation

GitHub Actions / test

value pack expansion can only appear inside a function argument list or tuple element
guard left == right else { return false }
}

do {
repeat try isEqual(each lhs, each rhs)
} catch {
return false
}

return true

}

7 changes: 6 additions & 1 deletion Sources/VergeComparator/TypedComparator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ extension TypedComparator {
*/
public static func equality<each T: Equatable>() -> Self where Self == AnyEqualityComparator<(repeat each T)> {
return .init { a, b in
areEqual((repeat each a), (repeat each b))

for (left, right) in repeat (each a, each b) {

Check failure on line 46 in Sources/VergeComparator/TypedComparator.swift

View workflow job for this annotation

GitHub Actions / test

value pack expansion can only appear inside a function argument list or tuple element
guard left == right else { return false }
}
return true

}
}

Expand Down

0 comments on commit e8009ab

Please sign in to comment.