Skip to content

Commit 10feb16

Browse files
committed
Reorder try await to latest syntax
1 parent 019d8ad commit 10feb16

13 files changed

+44
-44
lines changed

stdlib/public/Concurrency/AllSatisfy.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import Swift
1515
extension AsyncSequence {
1616
public func allSatisfy(_ predicate: (Element) async throws -> Bool) async rethrows -> Bool {
1717
var it = makeAsyncIterator()
18-
while let element = await try it.next() {
19-
if !(await try predicate(element)) {
18+
while let element = try await it.next() {
19+
if !(try await predicate(element)) {
2020
return false
2121
}
2222
}

stdlib/public/Concurrency/AsyncCompactMapSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct AsyncCompactMapSequence<Upstream, ElementOfResult>: AsyncSequence
3737

3838
public mutating func next() async rethrows -> ElementOfResult? {
3939
while true {
40-
guard let item = await try upstreamIterator?.next() else {
40+
guard let item = try await upstreamIterator?.next() else {
4141
return nil
4242
}
4343
if let transformed = await transform(item) {
@@ -80,11 +80,11 @@ public struct AsyncTryCompactMapSequence<Upstream, ElementOfResult>: AsyncSequen
8080

8181
public mutating func next() async throws -> ElementOfResult? {
8282
while true {
83-
guard let item = await try upstreamIterator?.next() else {
83+
guard let item = try await upstreamIterator?.next() else {
8484
return nil
8585
}
8686
do {
87-
if let transformed = await try transform(item) {
87+
if let transformed = try await transform(item) {
8888
return transformed
8989
}
9090
} catch {

stdlib/public/Concurrency/AsyncConcatSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public struct AsyncConcatSequence<Prefix, Suffix>: AsyncSequence where Prefix: A
3636
}
3737

3838
public mutating func next() async rethrows -> Prefix.Element? {
39-
if let item = await try prefixIterator?.next() {
39+
if let item = try await prefixIterator?.next() {
4040
return item
4141
}
4242
prefixIterator = nil
43-
return await try suffixIterator?.next()
43+
return try await suffixIterator?.next()
4444
}
4545

4646
public mutating func cancel() {

stdlib/public/Concurrency/AsyncDropWhileSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct AsyncDropWhileSequence<Upstream>: AsyncSequence where Upstream: As
3737

3838
public mutating func next() async rethrows -> Upstream.Element? {
3939
while true {
40-
guard let item = await try upstreamIterator?.next() else {
40+
guard let item = try await upstreamIterator?.next() else {
4141
return nil
4242
}
4343
if let predicate = self.predicate {
@@ -85,12 +85,12 @@ public struct AsyncTryDropWhileSequence<Upstream>: AsyncSequence where Upstream:
8585

8686
public mutating func next() async throws -> Upstream.Element? {
8787
while true {
88-
guard let item = await try upstreamIterator?.next() else {
88+
guard let item = try await upstreamIterator?.next() else {
8989
return nil
9090
}
9191
if let predicate = self.predicate {
9292
do {
93-
if !(await try predicate(item)) {
93+
if !(try await predicate(item)) {
9494
self.predicate = nil
9595
return item
9696
}

stdlib/public/Concurrency/AsyncFilterSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public struct AsyncFilterSequence<Upstream>: AsyncSequence where Upstream: Async
4141
}
4242

4343
public mutating func next() async rethrows -> Upstream.Element? {
44-
guard let item = await try upstreamIterator?.next() else {
44+
guard let item = try await upstreamIterator?.next() else {
4545
return nil
4646
}
4747
guard await predicate(item) else {
@@ -87,10 +87,10 @@ public struct AsyncTryFilterSequence<Upstream>: AsyncSequence where Upstream: As
8787
}
8888

8989
public mutating func next() async throws -> Upstream.Element? {
90-
guard let item = await try upstreamIterator?.next() else {
90+
guard let item = try await upstreamIterator?.next() else {
9191
return nil
9292
}
93-
guard await try predicate(item) else {
93+
guard try await predicate(item) else {
9494
upstreamIterator?.cancel()
9595
upstreamIterator = nil
9696
return nil

stdlib/public/Concurrency/AsyncFlatMapSequence.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public struct AsyncFlatMapSequence<Upstream, SegmentOfResult: AsyncSequence>: As
3737
}
3838

3939
public mutating func next() async rethrows -> SegmentOfResult.Element? {
40-
if let item = await try currentIterator?.next() {
40+
if let item = try await currentIterator?.next() {
4141
return item
4242
} else {
43-
guard let item = await try upstreamIterator?.next() else {
43+
guard let item = try await upstreamIterator?.next() else {
4444
return nil
4545
}
4646
let segment = await transform(item)
4747
currentIterator = segment.makeAsyncIterator()
48-
return await try currentIterator?.next()
48+
return try await currentIterator?.next()
4949
}
5050
}
5151

@@ -85,15 +85,15 @@ public struct AsyncTryFlatMapSequence<Upstream, SegmentOfResult: AsyncSequence>:
8585
}
8686

8787
public mutating func next() async throws -> SegmentOfResult.Element? {
88-
if let item = await try currentIterator?.next() {
88+
if let item = try await currentIterator?.next() {
8989
return item
9090
} else {
91-
guard let item = await try upstreamIterator?.next() else {
91+
guard let item = try await upstreamIterator?.next() else {
9292
return nil
9393
}
94-
let segment = await try transform(item)
94+
let segment = try await transform(item)
9595
currentIterator = segment.makeAsyncIterator()
96-
return await try currentIterator?.next()
96+
return try await currentIterator?.next()
9797
}
9898
}
9999

stdlib/public/Concurrency/AsyncMapSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct AsyncMapSequence<Upstream, Transformed>: AsyncSequence where Upstr
3838
}
3939

4040
public mutating func next() async rethrows -> Transformed? {
41-
guard let item = await try upstreamIterator?.next() else {
41+
guard let item = try await upstreamIterator?.next() else {
4242
return nil
4343
}
4444
return await transform(item)
@@ -79,10 +79,10 @@ public struct AsyncTryMapSequence<Upstream, Transformed>: AsyncSequence where Up
7979
}
8080

8181
public mutating func next() async throws -> Transformed? {
82-
guard let item = await try upstreamIterator?.next() else {
82+
guard let item = try await upstreamIterator?.next() else {
8383
return nil
8484
}
85-
return await try transform(item)
85+
return try await transform(item)
8686
}
8787

8888
public mutating func cancel() {

stdlib/public/Concurrency/AsyncPrefixWhileSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct AsyncPrefixWhileSequence<Upstream>: AsyncSequence where Upstream:
3636
}
3737

3838
public mutating func next() async rethrows -> Element? {
39-
guard let item = await try upstreamIterator?.next() else {
39+
guard let item = try await upstreamIterator?.next() else {
4040
return nil
4141
}
4242
guard await predicate(item) else {
@@ -80,10 +80,10 @@ public struct AsyncTryPrefixWhileSequence<Upstream>: AsyncSequence where Upstrea
8080
}
8181

8282
public mutating func next() async throws -> Element? {
83-
guard let item = await try upstreamIterator?.next() else {
83+
guard let item = try await upstreamIterator?.next() else {
8484
return nil
8585
}
86-
guard await try predicate(item) else {
86+
guard try await predicate(item) else {
8787
upstreamIterator?.cancel()
8888
upstreamIterator = nil
8989
return nil

stdlib/public/Concurrency/Contains.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import Swift
1515
extension AsyncSequence {
1616
public func contains(where predicate: (Element) async throws -> Bool) async rethrows -> Bool {
1717
var it = makeAsyncIterator()
18-
while let e = await try it.next() {
19-
if await try predicate(e) {
18+
while let e = try await it.next() {
19+
if try await predicate(e) {
2020
return true
2121
}
2222
}

stdlib/public/Concurrency/Count.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension AsyncSequence {
1616
public func count() async rethrows -> Int {
1717
var count = 0
1818
var it = makeAsyncIterator()
19-
while await try it.next() != nil {
19+
while try await it.next() != nil {
2020
count += 1
2121
}
2222
return count

stdlib/public/Concurrency/First.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import Swift
1515
extension AsyncSequence {
1616
public func first(where predicate: (Element) async throws -> Bool) async rethrows -> Element? {
1717
var it = makeAsyncIterator()
18-
while let element = await try it.next() {
19-
if await try predicate(element) {
18+
while let element = try await it.next() {
19+
if try await predicate(element) {
2020
return element
2121
}
2222
}
@@ -25,6 +25,6 @@ extension AsyncSequence {
2525

2626
public func first() async rethrows -> Element? {
2727
var it = makeAsyncIterator()
28-
return await try it.next()
28+
return try await it.next()
2929
}
3030
}

stdlib/public/Concurrency/MinMax.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ import Swift
1515
extension AsyncSequence {
1616
public func min(by areInIncreasingOrder: (Element, Element) async throws -> Bool) async rethrows -> Element? {
1717
var it = makeAsyncIterator()
18-
guard var result = await try it.next() else { return nil }
19-
while let e = await try it.next() {
20-
if await try areInIncreasingOrder(e, result) { result = e }
18+
guard var result = try await it.next() else { return nil }
19+
while let e = try await it.next() {
20+
if try await areInIncreasingOrder(e, result) { result = e }
2121
}
2222
return result
2323
}
2424

2525
public func max(by areInIncreasingOrder: (Element, Element) async throws -> Bool) async rethrows -> Element? {
2626
var it = makeAsyncIterator()
27-
guard var result = await try it.next() else { return nil }
28-
while let e = await try it.next() {
29-
if await try areInIncreasingOrder(result, e) { result = e }
27+
guard var result = try await it.next() else { return nil }
28+
while let e = try await it.next() {
29+
if try await areInIncreasingOrder(result, e) { result = e }
3030
}
3131
return result
3232
}
3333
}
3434

3535
extension AsyncSequence where Element: Comparable {
3636
public func min() async rethrows -> Element? {
37-
return await try min(by: <)
37+
return try await min(by: <)
3838
}
3939

4040
public func max() async rethrows -> Element? {
41-
return await try max(by: <)
41+
return try await max(by: <)
4242
}
4343
}

stdlib/public/Concurrency/Reduce.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ extension AsyncSequence {
1616
public func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (_ partialResult: Result, Element) async throws -> Result) async rethrows -> Result {
1717
var accumulator = initialResult
1818
var it = makeAsyncIterator()
19-
while let element = await try it.next() {
20-
accumulator = await try nextPartialResult(accumulator, element)
19+
while let element = try await it.next() {
20+
accumulator = try await nextPartialResult(accumulator, element)
2121
}
2222
return accumulator
2323
}
2424

2525
public func reduce<Result>(into initialResult: __owned Result, _ updateAccumulatingResult: (_ partialResult: inout Result, Element) async throws -> Void) async rethrows -> Result {
2626
var accumulator = initialResult
2727
var it = makeAsyncIterator()
28-
while let element = await try it.next() {
29-
await try updateAccumulatingResult(&accumulator, element)
28+
while let element = try await it.next() {
29+
try await updateAccumulatingResult(&accumulator, element)
3030
}
3131
return accumulator
3232
}

0 commit comments

Comments
 (0)