Skip to content

Commit b9bbe62

Browse files
committed
[Concurrency] Revise Async- related files doc
- Revise '// Prints' comments style like the other stdlib files - Remove verbose string interpolations and extra spaces - Remove some unneeded parentheses - Replace the majority of ' : ' with ': ' - Fix wrong indentation - Keep files with a single empty line at the end
1 parent 78a4cb8 commit b9bbe62

19 files changed

+90
-94
lines changed

stdlib/public/Concurrency/AsyncCompactMapSequence.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ extension AsyncSequence {
3030
/// returns `nil` in this case, which `compactMap(_:)` omits from the
3131
/// transformed asynchronous sequence.
3232
///
33-
/// let romanNumeralDict: [Int : String] =
33+
/// let romanNumeralDict: [Int: String] =
3434
/// [1: "I", 2: "II", 3: "III", 5: "V"]
3535
///
3636
/// let stream = Counter(howHigh: 5)
3737
/// .compactMap { romanNumeralDict[$0] }
3838
/// for await numeral in stream {
39-
/// print("\(numeral) ", terminator: " ")
39+
/// print(numeral, terminator: " ")
4040
/// }
41-
/// // Prints: I II III V
41+
/// // Prints "I II III V"
4242
///
4343
/// - Parameter transform: A mapping closure. `transform` accepts an element
4444
/// of this sequence as its parameter and returns a transformed value of the
@@ -141,4 +141,4 @@ extension AsyncCompactMapSequence: @unchecked Sendable
141141
extension AsyncCompactMapSequence.Iterator: @unchecked Sendable
142142
where Base.AsyncIterator: Sendable,
143143
Base.Element: Sendable,
144-
ElementOfResult: Sendable { }
144+
ElementOfResult: Sendable { }

stdlib/public/Concurrency/AsyncDropFirstSequence.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ extension AsyncSequence {
2222
///
2323
/// In this example, an asynchronous sequence called `Counter` produces `Int`
2424
/// values from `1` to `10`. The `dropFirst(_:)` method causes the modified
25-
/// sequence to ignore the values `0` through `4`, and instead emit `5` through `10`:
25+
/// sequence to ignore the values `1` through `3`, and instead emit `4` through `10`:
2626
///
2727
/// for await number in Counter(howHigh: 10).dropFirst(3) {
28-
/// print("\(number) ", terminator: " ")
28+
/// print(number, terminator: " ")
2929
/// }
30-
/// // prints "4 5 6 7 8 9 10"
30+
/// // Prints "4 5 6 7 8 9 10"
3131
///
3232
/// If the number of elements to drop exceeds the number of elements in the
3333
/// sequence, the result is an empty sequence.
@@ -144,4 +144,4 @@ extension AsyncDropFirstSequence: Sendable
144144
@available(SwiftStdlib 5.1, *)
145145
extension AsyncDropFirstSequence.Iterator: Sendable
146146
where Base.AsyncIterator: Sendable,
147-
Base.Element: Sendable { }
147+
Base.Element: Sendable { }

stdlib/public/Concurrency/AsyncDropWhileSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ extension AsyncSequence {
2828
/// let stream = Counter(howHigh: 10)
2929
/// .drop { $0 % 3 != 0 }
3030
/// for await number in stream {
31-
/// print("\(number) ", terminator: " ")
31+
/// print(number, terminator: " ")
3232
/// }
33-
/// // prints "3 4 5 6 7 8 9 10"
33+
/// // Prints "3 4 5 6 7 8 9 10"
3434
///
3535
/// After the predicate returns `false`, the sequence never executes it again,
3636
/// and from then on the sequence passes through elements from its underlying

stdlib/public/Concurrency/AsyncFilterSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ extension AsyncSequence {
2424
/// let stream = Counter(howHigh: 10)
2525
/// .filter { $0 % 2 == 0 }
2626
/// for await number in stream {
27-
/// print("\(number) ", terminator: " ")
27+
/// print(number, terminator: " ")
2828
/// }
29-
/// // Prints: 2 4 6 8 10
29+
/// // Prints "2 4 6 8 10"
3030
///
3131
/// - Parameter isIncluded: A closure that takes an element of the
3232
/// asynchronous sequence as its argument and returns a Boolean value

stdlib/public/Concurrency/AsyncFlatMapSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ extension AsyncSequence {
3131
/// let stream = Counter(howHigh: 5)
3232
/// .flatMap { Counter(howHigh: $0) }
3333
/// for await number in stream {
34-
/// print("\(number)", terminator: " ")
34+
/// print(number, terminator: " ")
3535
/// }
36-
/// // Prints: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
36+
/// // Prints "1 1 2 1 2 3 1 2 3 4 1 2 3 4 5"
3737
///
3838
/// - Parameter transform: A mapping closure. `transform` accepts an element
3939
/// of this sequence as its parameter and returns an `AsyncSequence`.

stdlib/public/Concurrency/AsyncIteratorProtocol.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ import Swift
2929
/// asynchronous, it shows the shape of a custom sequence and iterator, and how
3030
/// to use it as if it were asynchronous:
3131
///
32-
/// struct Counter : AsyncSequence {
32+
/// struct Counter: AsyncSequence {
3333
/// typealias Element = Int
3434
/// let howHigh: Int
3535
///
36-
/// struct AsyncIterator : AsyncIteratorProtocol {
36+
/// struct AsyncIterator: AsyncIteratorProtocol {
3737
/// let howHigh: Int
3838
/// var current = 1
39+
///
3940
/// mutating func next() async -> Int? {
4041
/// // A genuinely asynchronous implementation uses the `Task`
4142
/// // API to check for cancellation here and return early.
@@ -59,7 +60,7 @@ import Swift
5960
/// for await i in Counter(howHigh: 10) {
6061
/// print(i, terminator: " ")
6162
/// }
62-
/// // Prints: 1 2 3 4 5 6 7 8 9 10
63+
/// // Prints "1 2 3 4 5 6 7 8 9 10"
6364
///
6465
/// ### End of Iteration
6566
///

stdlib/public/Concurrency/AsyncMapSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ extension AsyncSequence {
3434
/// let stream = Counter(howHigh: 5)
3535
/// .map { romanNumeralDict[$0] ?? "(unknown)" }
3636
/// for await numeral in stream {
37-
/// print("\(numeral) ", terminator: " ")
37+
/// print(numeral, terminator: " ")
3838
/// }
39-
/// // Prints: I II III (unknown) V
39+
/// // Prints "I II III (unknown) V"
4040
///
4141
/// - Parameter transform: A mapping closure. `transform` accepts an element
4242
/// of this sequence as its parameter and returns a transformed value of the

stdlib/public/Concurrency/AsyncPrefixSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ extension AsyncSequence {
2525
/// sequence to pass through the first six values, then end.
2626
///
2727
/// for await number in Counter(howHigh: 10).prefix(6) {
28-
/// print("\(number) ")
28+
/// print(number, terminator: " ")
2929
/// }
30-
/// // prints "1 2 3 4 5 6"
30+
/// // Prints "1 2 3 4 5 6"
3131
///
3232
/// If the count passed to `prefix(_:)` exceeds the number of elements in the
3333
/// base sequence, the result contains all of the elements in the sequence.

stdlib/public/Concurrency/AsyncPrefixWhileSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extension AsyncSequence {
2929
/// let stream = Counter(howHigh: 10)
3030
/// .prefix { $0 % 2 != 0 || $0 % 3 != 0 }
3131
/// for try await number in stream {
32-
/// print("\(number) ", terminator: " ")
32+
/// print(number, terminator: " ")
3333
/// }
34-
/// // prints "1 2 3 4 5"
34+
/// // Prints "1 2 3 4 5"
3535
///
3636
/// - Parameter predicate: A closure that takes an element as a parameter and
3737
/// returns a Boolean value indicating whether the element should be

stdlib/public/Concurrency/AsyncSequence.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Swift
3030
/// for await i in Counter(howHigh: 10) {
3131
/// print(i, terminator: " ")
3232
/// }
33-
/// // Prints: 1 2 3 4 5 6 7 8 9 10
33+
/// // Prints "1 2 3 4 5 6 7 8 9 10"
3434
///
3535
/// An `AsyncSequence` doesn't generate or contain the values; it just defines
3636
/// how you access them. Along with defining the type of values as an associated
@@ -69,7 +69,7 @@ import Swift
6969
/// for await s in stream {
7070
/// print(s, terminator: " ")
7171
/// }
72-
/// // Prints: Odd Even Odd Even Odd Even Odd Even Odd Even
72+
/// // Prints "Odd Even Odd Even Odd Even Odd Even Odd Even"
7373
///
7474
@available(SwiftStdlib 5.1, *)
7575
@rethrows
@@ -108,7 +108,7 @@ extension AsyncSequence {
108108
/// $0 + $1
109109
/// }
110110
/// print(sum)
111-
/// // Prints: 10
111+
/// // Prints "10"
112112
///
113113
///
114114
/// - Parameters:
@@ -204,7 +204,7 @@ extension AsyncSequence {
204204
/// let containsDivisibleByThree = await Counter(howHigh: 10)
205205
/// .contains { $0 % 3 == 0 }
206206
/// print(containsDivisibleByThree)
207-
/// // Prints: true
207+
/// // Prints "true"
208208
///
209209
/// The predicate executes each time the asynchronous sequence produces an
210210
/// element, until either the predicate finds a match or the sequence ends.
@@ -231,7 +231,7 @@ extension AsyncSequence {
231231
/// let allLessThanTen = await Counter(howHigh: 10)
232232
/// .allSatisfy { $0 < 10 }
233233
/// print(allLessThanTen)
234-
/// // Prints: false
234+
/// // Prints "false"
235235
///
236236
/// The predicate executes each time the asynchronous sequence produces an
237237
/// element, until either the predicate returns `false` or the sequence ends.
@@ -263,7 +263,7 @@ extension AsyncSequence where Element: Equatable {
263263
/// let containsFive = await Counter(howHigh: 10)
264264
/// .contains(5)
265265
/// print(containsFive)
266-
/// // Prints: true
266+
/// // Prints "true"
267267
///
268268
/// - Parameter search: The element to find in the asynchronous sequence.
269269
/// - Returns: `true` if the method found the element in the asynchronous
@@ -306,7 +306,7 @@ extension AsyncSequence {
306306
/// let divisibleBy2And3 = await Counter(howHigh: 10)
307307
/// .first { $0 % 2 == 0 && $0 % 3 == 0 }
308308
/// print(divisibleBy2And3 ?? "none")
309-
/// // Prints: 6
309+
/// // Prints "6"
310310
///
311311
/// The predicate executes each time the asynchronous sequence produces an
312312
/// element, until either the predicate finds a match or the sequence ends.
@@ -357,7 +357,7 @@ extension AsyncSequence {
357357
/// let min = await RankCounter()
358358
/// .min { $0.rawValue < $1.rawValue }
359359
/// print(min ?? "none")
360-
/// // Prints: ace
360+
/// // Prints "ace"
361361
///
362362
/// - Parameter areInIncreasingOrder: A predicate that returns `true` if its
363363
/// first argument should be ordered before its second argument; otherwise,
@@ -412,7 +412,7 @@ extension AsyncSequence {
412412
/// let max = await RankCounter()
413413
/// .max { $0.rawValue < $1.rawValue }
414414
/// print(max ?? "none")
415-
/// // Prints: king
415+
/// // Prints "king"
416416
///
417417
/// - Parameter areInIncreasingOrder: A predicate that returns `true` if its
418418
/// first argument should be ordered before its second argument; otherwise,
@@ -449,7 +449,7 @@ extension AsyncSequence where Element: Comparable {
449449
/// let min = await Counter(howHigh: 10)
450450
/// .min()
451451
/// print(min ?? "none")
452-
/// // Prints: 1
452+
/// // Prints "1"
453453
///
454454
/// - Returns: The sequence’s minimum element. If the sequence has no
455455
/// elements, returns `nil`.
@@ -469,7 +469,7 @@ extension AsyncSequence where Element: Comparable {
469469
/// let max = await Counter(howHigh: 10)
470470
/// .max()
471471
/// print(max ?? "none")
472-
/// // Prints: 10
472+
/// // Prints "10"
473473
///
474474
/// - Returns: The sequence’s maximum element. If the sequence has no
475475
/// elements, returns `nil`.

stdlib/public/Concurrency/AsyncStream.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ import Swift
9191
/// produces it:
9292
///
9393
/// for await quake in QuakeMonitor.quakes {
94-
/// print ("Quake: \(quake.date)")
94+
/// print("Quake: \(quake.date)")
9595
/// }
96-
/// print ("Stream finished.")
96+
/// print("Stream finished.")
9797
///
9898
@available(SwiftStdlib 5.1, *)
9999
public struct AsyncStream<Element> {
@@ -272,18 +272,18 @@ public struct AsyncStream<Element> {
272272
///
273273
/// let stream = AsyncStream<Int>(Int.self,
274274
/// bufferingPolicy: .bufferingNewest(5)) { continuation in
275-
/// Task.detached {
276-
/// for _ in 0..<100 {
277-
/// await Task.sleep(1 * 1_000_000_000)
278-
/// continuation.yield(Int.random(in: 1...10))
279-
/// }
280-
/// continuation.finish()
275+
/// Task.detached {
276+
/// for _ in 0..<100 {
277+
/// await Task.sleep(1 * 1_000_000_000)
278+
/// continuation.yield(Int.random(in: 1...10))
281279
/// }
280+
/// continuation.finish()
282281
/// }
282+
/// }
283283
///
284284
/// // Call point:
285285
/// for await random in stream {
286-
/// print ("\(random)")
286+
/// print(random)
287287
/// }
288288
///
289289
public init(
@@ -319,15 +319,13 @@ public struct AsyncStream<Element> {
319319
/// the `unfolding` parameter label.
320320
///
321321
/// let stream = AsyncStream<Int> {
322-
/// await Task.sleep(1 * 1_000_000_000)
323-
/// return Int.random(in: 1...10)
324-
/// }
325-
/// onCancel: { @Sendable () in print ("Canceled.") }
326-
/// )
322+
/// await Task.sleep(1 * 1_000_000_000)
323+
/// return Int.random(in: 1...10)
324+
/// } onCancel: { @Sendable () in print("Cancelled.") }
327325
///
328326
/// // Call point:
329327
/// for await random in stream {
330-
/// print ("\(random)")
328+
/// print(random)
331329
/// }
332330
///
333331
///

stdlib/public/Concurrency/AsyncStreamBuffer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,4 +592,3 @@ final class _AsyncStreamCriticalStorage<Contents>: @unchecked Sendable {
592592
return storage
593593
}
594594
}
595-

stdlib/public/Concurrency/AsyncThrowingCompactMapSequence.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension AsyncSequence {
3030
/// transformed asynchronous sequence. When the value is `5`, the closure
3131
/// throws `MyError`, terminating the sequence.
3232
///
33-
/// let romanNumeralDict: [Int : String] =
33+
/// let romanNumeralDict: [Int: String] =
3434
/// [1: "I", 2: "II", 3: "III", 5: "V"]
3535
///
3636
/// do {
@@ -42,12 +42,12 @@ extension AsyncSequence {
4242
/// return romanNumeralDict[value]
4343
/// }
4444
/// for try await numeral in stream {
45-
/// print("\(numeral) ", terminator: " ")
45+
/// print(numeral, terminator: " ")
4646
/// }
4747
/// } catch {
4848
/// print("Error: \(error)")
4949
/// }
50-
/// // Prints: I II III Error: MyError()
50+
/// // Prints "I II III Error: MyError()"
5151
///
5252
/// - Parameter transform: An error-throwing mapping closure. `transform`
5353
/// accepts an element of this sequence as its parameter and returns a
@@ -162,4 +162,3 @@ extension AsyncThrowingCompactMapSequence: @unchecked Sendable
162162
extension AsyncThrowingCompactMapSequence.Iterator: @unchecked Sendable
163163
where Base.AsyncIterator: Sendable,
164164
Base.Element: Sendable { }
165-

stdlib/public/Concurrency/AsyncThrowingDropWhileSequence.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ extension AsyncSequence {
3030
/// throws without ever printing anything.
3131
///
3232
/// do {
33-
/// let stream = Counter(howHigh: 10)
33+
/// let stream = Counter(howHigh: 10)
3434
/// .drop {
3535
/// if $0 % 2 == 0 {
3636
/// throw EvenError()
3737
/// }
3838
/// return $0 < 5
3939
/// }
4040
/// for try await number in stream {
41-
/// print("\(number) ")
41+
/// print(number)
4242
/// }
4343
/// } catch {
44-
/// print ("\(error)")
44+
/// print(error)
4545
/// }
46-
/// // Prints: EvenError()
46+
/// // Prints "EvenError()"
4747
///
4848
/// After the predicate returns `false`, the sequence never executes it again,
4949
/// and from then on the sequence passes through elements from its underlying

stdlib/public/Concurrency/AsyncThrowingFilterSequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ extension AsyncSequence {
2323
/// but also throws an error for values divisible by 5:
2424
///
2525
/// do {
26-
/// let stream = Counter(howHigh: 10)
26+
/// let stream = Counter(howHigh: 10)
2727
/// .filter {
2828
/// if $0 % 5 == 0 {
2929
/// throw MyError()
3030
/// }
3131
/// return $0 % 2 == 0
3232
/// }
3333
/// for try await number in stream {
34-
/// print("\(number) ", terminator: " ")
34+
/// print(number, terminator: " ")
3535
/// }
3636
/// } catch {
3737
/// print("Error: \(error)")
3838
/// }
39-
/// // Prints: 2 4 Error: MyError()
39+
/// // Prints "2 4 Error: MyError()"
4040
///
4141
/// - Parameter isIncluded: An error-throwing closure that takes an element
4242
/// of the asynchronous sequence as its argument and returns a Boolean value

0 commit comments

Comments
 (0)