From e8009abacef05a23756a91356a976a9f6d006c57 Mon Sep 17 00:00:00 2001 From: Muukii Date: Mon, 21 Oct 2024 15:31:24 +0900 Subject: [PATCH] Patch --- Sources/VergeComparator/PackedCompare.swift | 20 ++++--------------- Sources/VergeComparator/TypedComparator.swift | 7 ++++++- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Sources/VergeComparator/PackedCompare.swift b/Sources/VergeComparator/PackedCompare.swift index 5d2752bd27..799eb34c5c 100644 --- a/Sources/VergeComparator/PackedCompare.swift +++ b/Sources/VergeComparator/PackedCompare.swift @@ -1,23 +1,11 @@ @_spi(Internal) public func areEqual(_ lhs: (repeat each Element), _ rhs: (repeat each Element)) -> Bool { - - // https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md - - func isEqual(_ left: T, _ right: T) throws { - if left == right { - return - } - - throw NotEqual() + + for (left, right) in repeat (each lhs, each rhs) { + guard left == right else { return false } } - - do { - repeat try isEqual(each lhs, each rhs) - } catch { - return false - } - return true + } diff --git a/Sources/VergeComparator/TypedComparator.swift b/Sources/VergeComparator/TypedComparator.swift index 288c13c4f8..60de9d6c49 100644 --- a/Sources/VergeComparator/TypedComparator.swift +++ b/Sources/VergeComparator/TypedComparator.swift @@ -42,7 +42,12 @@ extension TypedComparator { */ public static func equality() -> 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) { + guard left == right else { return false } + } + return true + } }