From 7db34dc7aba5d98f0f19ba36e3d64be5a22fe5b9 Mon Sep 17 00:00:00 2001 From: NachoSoto Date: Tue, 6 Jun 2023 07:28:54 -0700 Subject: [PATCH] `Dictionary.MergeStrategy`: simplify implementation Follow up to #2582. Didn't realize that the issue was the `Value` shouldn't have been there, since it could use the parent `associatedtype` from `Dictionary`. --- Sources/FoundationExtensions/Dictionary+Extensions.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/FoundationExtensions/Dictionary+Extensions.swift b/Sources/FoundationExtensions/Dictionary+Extensions.swift index 79b7a832af..ed3a3023d9 100644 --- a/Sources/FoundationExtensions/Dictionary+Extensions.swift +++ b/Sources/FoundationExtensions/Dictionary+Extensions.swift @@ -31,14 +31,14 @@ extension Dictionary { extension Dictionary { /// Merge strategy to use for any duplicate keys. - enum MergeStrategy { + enum MergeStrategy { /// Keep the original value. case keepOriginalValue /// Overwrite the original value. case overwriteValue - var combine: (NewValue, NewValue) -> NewValue { + var combine: (Value, Value) -> Value { switch self { case .keepOriginalValue: return { original, _ in original } @@ -59,7 +59,7 @@ extension Dictionary { /// closure that returns the desired value for the final dictionary. The default is `overwriteValue`. /// - Returns: A new dictionary with the combined keys and values of this /// dictionary and `other`. - func merging(_ other: [Key: Value], strategy: MergeStrategy = .overwriteValue) -> [Key: Value] { + func merging(_ other: [Key: Value], strategy: MergeStrategy = .overwriteValue) -> [Key: Value] { return self.merging(other, uniquingKeysWith: strategy.combine) } @@ -70,7 +70,7 @@ extension Dictionary { /// - other: A dictionary to merge. /// - strategy: The merge strategy to use for any duplicate keys. The strategy provides a /// closure that returns the desired value for the final dictionary. The default is `overwriteValue`. - mutating func merge(_ other: [Key: Value], strategy: MergeStrategy = .overwriteValue) { + mutating func merge(_ other: [Key: Value], strategy: MergeStrategy = .overwriteValue) { self.merge(other, uniquingKeysWith: strategy.combine) }