From bcfd75ff68b0ac941046862c1cde9c5d358dcec4 Mon Sep 17 00:00:00 2001 From: zgjie Date: Mon, 6 Apr 2020 02:06:24 +0800 Subject: [PATCH] Replace the `firstElementPassingTest` function come from RSCore with the native function `first(where:)`. --- .../Account/Feedly/OAuthAuthorizationCodeGranting.swift | 4 ++-- Mac/MainWindow/Timeline/Cell/SingleLineTextFieldSizer.swift | 2 +- iOS/Article/OpenInSafariActivity.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift b/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift index 735f33bff..836989e78 100644 --- a/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift +++ b/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift @@ -70,12 +70,12 @@ public extension OAuthAuthorizationResponse { guard let queryItems = components.queryItems, !queryItems.isEmpty else { throw URLError(.unsupportedURL) } - let code = queryItems.firstElementPassingTest { $0.name.lowercased() == "code" } + let code = queryItems.first { $0.name.lowercased() == "code" } guard let codeValue = code?.value, !codeValue.isEmpty else { throw URLError(.unsupportedURL) } - let state = queryItems.firstElementPassingTest { $0.name.lowercased() == "state" } + let state = queryItems.first { $0.name.lowercased() == "state" } let stateValue = state?.value self.init(code: codeValue, state: stateValue) diff --git a/Mac/MainWindow/Timeline/Cell/SingleLineTextFieldSizer.swift b/Mac/MainWindow/Timeline/Cell/SingleLineTextFieldSizer.swift index ed18581e9..e40db7235 100644 --- a/Mac/MainWindow/Timeline/Cell/SingleLineTextFieldSizer.swift +++ b/Mac/MainWindow/Timeline/Cell/SingleLineTextFieldSizer.swift @@ -53,7 +53,7 @@ final class SingleLineTextFieldSizer { // that members of such a dictionary were mutated after insertion. // We use just an array of sizers now — which is totally fine, // because there’s only going to be like three of them. - if let cachedSizer = sizers.firstElementPassingTest({ $0.font == font }) { + if let cachedSizer = sizers.first(where: { $0.font == font }) { return cachedSizer } diff --git a/iOS/Article/OpenInSafariActivity.swift b/iOS/Article/OpenInSafariActivity.swift index a157345fb..9b5b5ed8f 100644 --- a/iOS/Article/OpenInSafariActivity.swift +++ b/iOS/Article/OpenInSafariActivity.swift @@ -37,7 +37,7 @@ class OpenInSafariActivity: UIActivity { } override func perform() { - guard let url = activityItems?.firstElementPassingTest({ $0 is URL }) as? URL else { + guard let url = activityItems?.first(where: { $0 is URL }) as? URL else { activityDidFinish(false) return }