@@ -2135,13 +2135,13 @@ Erroneous code examples:
2135
2135
# use std::pin::Pin;
2136
2136
# use std::future::Future;
2137
2137
# use std::task::{Context, Poll};
2138
-
2138
+ #
2139
2139
# struct WakeOnceThenComplete(bool);
2140
-
2140
+ #
2141
2141
# fn wake_and_yield_once() -> WakeOnceThenComplete {
2142
2142
# WakeOnceThenComplete(false)
2143
2143
# }
2144
-
2144
+ #
2145
2145
# impl Future for WakeOnceThenComplete {
2146
2146
# type Output = ();
2147
2147
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
@@ -2154,7 +2154,7 @@ Erroneous code examples:
2154
2154
# }
2155
2155
# }
2156
2156
# }
2157
-
2157
+ #
2158
2158
fn foo() {
2159
2159
wake_and_yield_once().await // `await` is used outside `async` context
2160
2160
}
@@ -2168,13 +2168,13 @@ an async context, like an `async fn` or an `async` block.
2168
2168
# use std::pin::Pin;
2169
2169
# use std::future::Future;
2170
2170
# use std::task::{Context, Poll};
2171
-
2171
+ #
2172
2172
# struct WakeOnceThenComplete(bool);
2173
-
2173
+ #
2174
2174
# fn wake_and_yield_once() -> WakeOnceThenComplete {
2175
2175
# WakeOnceThenComplete(false)
2176
2176
# }
2177
-
2177
+ #
2178
2178
# impl Future for WakeOnceThenComplete {
2179
2179
# type Output = ();
2180
2180
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
@@ -2187,9 +2187,16 @@ an async context, like an `async fn` or an `async` block.
2187
2187
# }
2188
2188
# }
2189
2189
# }
2190
-
2190
+ #
2191
2191
async fn foo() {
2192
- wake_and_yield_once().await // `await` is used within `async` context
2192
+ wake_and_yield_once().await // `await` is used within `async` function
2193
+ }
2194
+
2195
+ fn bar(x: u8) -> impl Future<Output = u8> {
2196
+ async move {
2197
+ wake_and_yield_once().await; // `await` is used within `async` block
2198
+ x
2199
+ }
2193
2200
}
2194
2201
```
2195
2202
"## ,
0 commit comments