Skip to content

Commit 7cc66ed

Browse files
committed
Merge pull request #58930 from Jager-yoo/revise-concurrency-doc
[Concurrency] Revise `Async-` related files doc (cherry picked from commit 4b0824c)
1 parent db63a92 commit 7cc66ed

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
/// asychronous, 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 asychronous 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`.

0 commit comments

Comments
 (0)