Merge pull request #1968 from zgjie/master

Replace the `firstElementPassingTest` function come from RSCore with …
This commit is contained in:
Maurice Parker 2020-04-05 13:19:27 -05:00 committed by GitHub
commit 0e5a9f7ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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 theres 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
}

View File

@ -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
}