Skip to content

Commit cb803f0

Browse files
committed
Add section about how AsyncFn commits us also
As it turns out, `AsyncFn()` probably commits our direction on generalized `async` trait bound modifiers to the same degree as `async Fn()`. Let's describe this. CE brought up this excellent point.
1 parent 186ce20 commit cb803f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

text/3668-async-closures.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,14 @@ let _ = || {
563563

564564
Reusing the `async` keyword allows users to understand what an `async Fn() -> T` trait bound does by analogy, since they already should know that adding `async` to some `fn foo() -> T` makes it return an `impl Future<Output = T>` instead of the type `T`.
565565

566+
### Wouldn't `F: AsyncFn() -> T` save more space for `async` trait bound modifiers?
567+
568+
Some have argued that using `F: AsyncFn() -> T` rather than `F: async Fn() -> T` would better save space for whatever we might want the semantics to be if we were to later adopt generalized `async` trait bound modifiers.
569+
570+
We don't think this is correct in a practical sense. If we were give meaning to and stabilize `AsyncFn()` trait bounds, and then later, due to work on generalized `async` trait bound modifiers, we were to give a different meaning to `async Fn()`, that would seem so undesirable that it's hard to imagine we would ever actually do it. People would too strongly expect `AsyncFn()` and `async Fn()` to work in the same way.
571+
572+
If that's true, then stabilizing either of `AsyncFn()` or `async Fn()` trait bounds would potentially affect our decisions about generalized `async` trait bound modifiers to the same degree.
573+
566574
### Why do we even need `AsyncFnOnce`?
567575

568576
We could desugar `async FnOnce() -> T` directly to `FnOnce<(), Output: Future<Output = T>>`. It seems overly complicated for an implementation detail, since users should never care what's *behind* the `AsyncFnOnce` trait bound.

0 commit comments

Comments
 (0)