You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/3668-async-closure.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -303,7 +303,7 @@ The reason that these implementations are built-in is because using blanket impl
303
303
304
304
Some stable types that implement `async Fn()` today include, e.g.:
305
305
306
-
```rust!
306
+
```rust
307
307
// Async functions:
308
308
asyncfnfoo() {}
309
309
@@ -361,7 +361,7 @@ The closure captures `vec` with some `&'closure mut Vec<String>` which lives unt
361
361
362
362
As another example:
363
363
364
-
```rust!
364
+
```rust
365
365
letstring:String="Hello, world".into();
366
366
367
367
letclosure=asyncmove|| {
@@ -510,21 +510,21 @@ These limitations, plus the fact that the underlying trait should have no effect
510
510
511
511
`async ||` is analogous with `async fn`, and has an intuitive, first-class way to declare the return type of the future:
512
512
513
-
```rust!
513
+
```rust
514
514
letc=async||->i32 { 0 };
515
515
```
516
516
517
517
There isn't currently a way to annotate the future's return type in a closure that returns a future:
518
518
519
-
```rust!
519
+
```rust
520
520
letc=||->/* ??? */async { 0 };
521
521
```
522
522
523
523
We could reuse `impl Future` to give users the ability to annotate the type of the future returned by the closure in this position, but it would require giving yet another subtly different meaning to `impl Trait`, since async closures return a *different* type when being called by-ref or by-move.
524
524
525
525
This also would have subtle limitations, e.g.:
526
526
527
-
```rust!
527
+
```rust
528
528
// Easy to reanalyze as an async closure.
529
529
let_=||async { do_stuff().await };
530
530
@@ -556,7 +556,7 @@ We should be able to detect when users write `|| async {}` -- and subsequently h
556
556
557
557
A similar problem could occur if users try to write "old style" trait bounds with two generic parameters `F: Fn() -> Fut` and `Fut: Future<Output = T>`. For example:
0 commit comments