@@ -80,24 +80,26 @@ import Swift
80
80
/// calls `stopMonitoring()` on the monitor.
81
81
/// 5. Calls `startMonitoring` on the `QuakeMonitor`.
82
82
///
83
- /// extension QuakeMonitor {
83
+ /// ```
84
+ /// extension QuakeMonitor {
84
85
///
85
- /// static var throwingQuakes: AsyncThrowingStream<Quake, Error> {
86
- /// AsyncThrowingStream { continuation in
87
- /// let monitor = QuakeMonitor()
88
- /// monitor.quakeHandler = { quake in
89
- /// continuation.yield(quake)
90
- /// }
91
- /// monitor.errorHandler = { error in
92
- /// continuation.finish(throwing: error)
93
- /// }
94
- /// continuation.onTermination = { @Sendable _ in
95
- /// monitor.stopMonitoring()
96
- /// }
97
- /// monitor.startMonitoring()
86
+ /// static var throwingQuakes: AsyncThrowingStream<Quake, Error> {
87
+ /// AsyncThrowingStream { continuation in
88
+ /// let monitor = QuakeMonitor()
89
+ /// monitor.quakeHandler = { quake in
90
+ /// continuation.yield(quake)
98
91
/// }
92
+ /// monitor.errorHandler = { error in
93
+ /// continuation.finish(throwing: error)
94
+ /// }
95
+ /// continuation.onTermination = { @Sendable _ in
96
+ /// monitor.stopMonitoring()
97
+ /// }
98
+ /// monitor.startMonitoring()
99
99
/// }
100
100
/// }
101
+ /// }
102
+ /// ```
101
103
///
102
104
///
103
105
/// Because the stream is an `AsyncSequence`, the call point uses the
@@ -289,7 +291,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
289
291
/// The following example shows an `AsyncStream` created with this
290
292
/// initializer that produces 100 random numbers on a one-second interval,
291
293
/// calling `yield(_:)` to deliver each element to the awaiting call point.
292
- /// When the `for` loop exits and the stream finishes by calling the
294
+ /// When the `for` loop exits, the stream finishes by calling the
293
295
/// continuation's `finish()` method. If the random number is divisble by 5
294
296
/// with no remainder, the stream throws a `MyRandomNumberError`.
295
297
///
0 commit comments