From 75b62abd7212cad32805bb0b35df5d963a8c1ebf Mon Sep 17 00:00:00 2001 From: "Alkenso (Vladimir Vashurkin)" Date: Mon, 26 Feb 2024 18:45:17 +0200 Subject: [PATCH] Add proper documentation to `Dictionary.filter(remaining: ...)` --- .../Common/Extensions - Collections.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/SpellbookFoundation/Common/Extensions - Collections.swift b/Sources/SpellbookFoundation/Common/Extensions - Collections.swift index 9959952..489a5ae 100644 --- a/Sources/SpellbookFoundation/Common/Extensions - Collections.swift +++ b/Sources/SpellbookFoundation/Common/Extensions - Collections.swift @@ -95,6 +95,16 @@ extension Dictionary { } extension Dictionary { + /// Returns a new dictionary containing the key-value pairs of the dictionary + /// that satisfy the given predicate. + /// Collects unsatisfied elements into `remaining` dictionary. + /// + /// - Parameter isIncluded: A closure that takes a key-value pair as its + /// argument and returns a Boolean value indicating whether the pair + /// should be included in the returned dictionary. + /// - Parameter remaining: A dictionary to collect elements that are + /// not included into returned dictionary. + /// - Returns: A dictionary of the key-value pairs that `isIncluded` allows. public func filter(remaining: inout [Key: Value], _ isIncluded: (Element) throws -> Bool) rethrows -> [Key: Value] { var filtered: [Key: Value] = [:] for (key, value) in self {