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
In our [previous post][pp], we [hypothesized](https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html#hypothesis-this-is-uncommon) that this problem might not occur often in practice. However, our case studies found that it comes up quite frequently, and so we decided that a solution is needed. We explored a number of solutions and concluded that associated return types are the most practical.
103
103
104
-
**Status:** Associated return types have an experimental implementation and we are currently drafting an RFC. There are several open bugs that will need to be fixed.
104
+
**Status:** Associated return types have an experimental implementation and we are currently drafting an RFC. There are several open bugs that will need to be fixed. We are considering more concise syntax for the future (see below).
@@ -177,7 +177,9 @@ To make this workaround easier in the near term, we hope to provide a proc macro
177
177
178
178
### Send bounds are verbose, especially for traits with lots of methods
179
179
180
-
The associated return type proposal works great for traits with a single method, but it can be annoying for traits that have lots of methods. One convenient solution is to use the "trait alias pattern" (if [RFC 1733](https://github.com/rust-lang/rust/issues/41517) were stabilized, this would be easier):
180
+
The associated return type proposal works great for traits with a single method, but it can be annoying for traits that have lots of methods. One convenient solution is to use the "trait alias pattern":[^trait-alias]
181
+
182
+
[^trait-alias]: If [RFC 1733](https://github.com/rust-lang/rust/issues/41517) were stabilized, this would be easier.
181
183
182
184
```rust
183
185
traitSendHealthCheck
@@ -193,7 +195,16 @@ where
193
195
{}
194
196
```
195
197
196
-
Using a pattern like this means you can write `T: SendHealthCheck`. We hope to provide a proc macro to write these trait aliases for you. In the future, something like [trait transformers] may provide a more concise syntax.
198
+
Using a pattern like this means you can write `T: SendHealthCheck`. We plan to provide a proc macro to write these trait aliases for you, so you can write something more like this instead:
199
+
200
+
```rust
201
+
#[make_alias(Send="SendHealthCheck")]
202
+
traitHealthCheck {
203
+
asyncfncheck(&mutself) ->bool;
204
+
}
205
+
```
206
+
207
+
In the future, something like [trait transformers] may provide a more concise syntax without a proc macro. But because there are use cases that require the kind of fine-grained control provided by associated return types, we opted to stabilize them first and consider more concise syntaxes later.
0 commit comments