@@ -80,24 +80,26 @@ import Swift
8080/// calls `stopMonitoring()` on the monitor.
8181/// 5. Calls `startMonitoring` on the `QuakeMonitor`.
8282///
83- /// extension QuakeMonitor {
83+ /// ```
84+ /// extension QuakeMonitor {
8485///
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)
9891/// }
92+ /// monitor.errorHandler = { error in
93+ /// continuation.finish(throwing: error)
94+ /// }
95+ /// continuation.onTermination = { @Sendable _ in
96+ /// monitor.stopMonitoring()
97+ /// }
98+ /// monitor.startMonitoring()
9999/// }
100100/// }
101+ /// }
102+ /// ```
101103///
102104///
103105/// Because the stream is an `AsyncSequence`, the call point uses the
@@ -289,7 +291,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
289291 /// The following example shows an `AsyncStream` created with this
290292 /// initializer that produces 100 random numbers on a one-second interval,
291293 /// 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
293295 /// continuation's `finish()` method. If the random number is divisble by 5
294296 /// with no remainder, the stream throws a `MyRandomNumberError`.
295297 ///
0 commit comments