From 09a372bc45fde16fd42257ab6f78b8deeecf720b Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期三, 16 四月 2025 16:38:05 +0800 Subject: [PATCH] fix bug --- Pods/SwifterSwift/Sources/SwifterSwift/SwiftStdlib/SequenceExtensions.swift | 45 ++++++++++++++++++++++++--------------------- 1 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Pods/SwifterSwift/Sources/SwifterSwift/SwiftStdlib/SequenceExtensions.swift b/Pods/SwifterSwift/Sources/SwifterSwift/SwiftStdlib/SequenceExtensions.swift index be38831..f1c6d80 100644 --- a/Pods/SwifterSwift/Sources/SwifterSwift/SwiftStdlib/SequenceExtensions.swift +++ b/Pods/SwifterSwift/Sources/SwifterSwift/SwiftStdlib/SequenceExtensions.swift @@ -176,14 +176,14 @@ /// - Parameter compare: Comparison function that will determine the ordering. /// - Returns: The sorted array. func sorted<T>(by map: (Element) throws -> T, with compare: (T, T) -> Bool) rethrows -> [Element] { - return try sorted { compare(try map($0), try map($1)) } + return try sorted { try compare(map($0), map($1)) } } /// SwifterSwift: Return a sorted array based on a key path. /// /// - Parameter keyPath: Key path to sort by. The key path type must be Comparable. /// - Returns: The sorted array. - func sorted<T: Comparable>(by keyPath: KeyPath<Element, T>) -> [Element] { + func sorted(by keyPath: KeyPath<Element, some Comparable>) -> [Element] { return sorted { $0[keyPath: keyPath] < $1[keyPath: keyPath] } } @@ -191,7 +191,7 @@ /// /// - Parameter map: Function that defines the property to sort by. The output type must be Comparable. /// - Returns: The sorted array. - func sorted<T: Comparable>(by map: (Element) throws -> T) rethrows -> [Element] { + func sorted(by map: (Element) throws -> some Comparable) rethrows -> [Element] { return try sorted { try map($0) < map($1) } } @@ -201,8 +201,8 @@ /// - Parameters: /// - keyPath1: Key path to sort by. Must be Comparable. /// - keyPath2: Key path to sort by in case the values of `keyPath1` match. Must be Comparable. - func sorted<T: Comparable, U: Comparable>(by keyPath1: KeyPath<Element, T>, - and keyPath2: KeyPath<Element, U>) -> [Element] { + func sorted(by keyPath1: KeyPath<Element, some Comparable>, + and keyPath2: KeyPath<Element, some Comparable>) -> [Element] { return sorted { if $0[keyPath: keyPath1] != $1[keyPath: keyPath1] { return $0[keyPath: keyPath1] < $1[keyPath: keyPath1] @@ -211,14 +211,14 @@ } } - /// SwifterSwift: Returns a sorted sequence based on two map functions. The second one will be used in case the values - /// of the first one match. + /// SwifterSwift: Returns a sorted sequence based on two map functions. The second one will be used in case the + /// values of the first one match. /// /// - Parameters: /// - map1: Map function to sort by. Output type must be Comparable. /// - map2: Map function to sort by in case the values of `map1` match. Output type must be Comparable. - func sorted<T: Comparable, U: Comparable>(by map1: (Element) throws -> T, - and map2: (Element) throws -> U) rethrows -> [Element] { + func sorted(by map1: (Element) throws -> some Comparable, + and map2: (Element) throws -> some Comparable) rethrows -> [Element] { return try sorted { let value10 = try map1($0) let value11 = try map1($1) @@ -236,9 +236,10 @@ /// - keyPath1: Key path to sort by. Must be Comparable. /// - keyPath2: Key path to sort by in case the values of `keyPath1` match. Must be Comparable. /// - keyPath3: Key path to sort by in case the values of `keyPath1` and `keyPath2` match. Must be Comparable. - func sorted<T: Comparable, U: Comparable, V: Comparable>(by keyPath1: KeyPath<Element, T>, - and keyPath2: KeyPath<Element, U>, - and keyPath3: KeyPath<Element, V>) -> [Element] { + func sorted(by keyPath1: KeyPath<Element, some Comparable>, + and keyPath2: KeyPath<Element, some Comparable>, + and keyPath3: KeyPath<Element, some Comparable>) + -> [Element] { return sorted { if $0[keyPath: keyPath1] != $1[keyPath: keyPath1] { return $0[keyPath: keyPath1] < $1[keyPath: keyPath1] @@ -250,23 +251,25 @@ } } - /// SwifterSwift: Returns a sorted sequence based on three map functions. Whenever the values of one map function match, the - /// next one will be used. + /// SwifterSwift: Returns a sorted sequence based on three map functions. Whenever the values of one map function + /// match, the next one will be used. /// /// - Parameters: /// - map1: Map function to sort by. Output type must be Comparable. /// - map2: Map function to sort by in case the values of `map1` match. Output type must be Comparable. - /// - map3: Map function to sort by in case the values of `map1` and `map2` match. Output type must be Comparable. - func sorted<T: Comparable, U: Comparable, V: Comparable>(by map1: (Element) throws -> T, - and map2: (Element) throws -> U, - and map3: (Element) throws -> V) rethrows -> [Element] { + /// - map3: Map function to sort by in case the values of `map1` and `map2` match. + /// Output type must be Comparable. + func sorted(by map1: (Element) throws -> some Comparable, + and map2: (Element) throws -> some Comparable, + and map3: (Element) throws -> some Comparable) rethrows + -> [Element] { return try sorted { let value10 = try map1($0) let value11 = try map1($1) if value10 != value11 { return value10 < value11 } - + let value20 = try map2($0) let value21 = try map2($1) if value20 != value21 { @@ -326,8 +329,8 @@ /// - Parameters: /// - map: Function for `Element` to compare. /// - value: The value to compare with `Element` property. - /// - Returns: The first element of the collection that has property by given map function equals to given `value` or - /// `nil` if there is no such element. + /// - Returns: The first element of the collection that has property by given map function equals to given `value` + /// or `nil` if there is no such element. func first<T: Equatable>(where map: (Element) throws -> T, equals value: T) rethrows -> Element? { return try first { try map($0) == value } } -- Gitblit v1.7.1