Skip to content

Commit 3938f65

Browse files
Add missing generics
1 parent 29582aa commit 3938f65

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

text/3668-async-closure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Users often employ `Fn()` trait bounds to write more functional code and reduce
3434
[^alloc]: Or return a concrete future type, like `F: Fn() -> Pin<Box<dyn Future<Output = T>>>`.
3535

3636
```rust
37-
async fn for_each_city(mut f: F)
37+
async fn for_each_city<F, Fut>(mut f: F)
3838
where
3939
F: for<'c> FnMut(&'c str) -> Fut,
4040
Fut: Future<Output = ()>,
@@ -293,7 +293,7 @@ Notably, we can now express higher-ranked async callback bounds:
293293

294294
```rust
295295
// We could also use APIT: `mut f: impl async FnMut(&str)`.
296-
async fn for_each_city(mut f: F)
296+
async fn for_each_city<F>(mut f: F)
297297
where
298298
F: async FnMut(&str),
299299
// ...which is sugar for:
@@ -532,7 +532,7 @@ We should be able to detect when users write `|| async {}` -- and subsequently h
532532
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:
533533

534534
```rust!
535-
async fn for_each_city(cb: F)
535+
async fn for_each_city<F, Fut>(cb: F)
536536
where
537537
F: Fn(&str) -> Fut,
538538
Fut: Future<Output = ()>,

0 commit comments

Comments
 (0)