this post was submitted on 22 Jan 2026
20 points (100.0% liked)
Rust
7692 readers
26 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If I understand what you're asking...
This leaves out some details/specifics out to simplify. But basically:
This meant that you couldn't just have (stable) async methods in traits, not because of async itself, but because you couldn't use impl Trait in return positions in trait methods, in general.
Box<dyn Future>was an unideal workaround (not zero-cost, and otherdyndrawbacks).async_traitwas a proc macro solution that generated code with that workaround. soBox<dyn Future>was never a desugaring done by the language/compiler.now that we have (stable) impl Trait in return positions in trait methods, all this dance is not strictly needed anymore, and hasn't been needed for a while.
I ran into the same issue not so long ago and at least for
no_stdI had to resort to using theasync_traitcrate. (The project isno_stdbut hasalloc)I can't recall the exact error so it might have been due to mixing async and non-async methods in the same trait. I would have to look at it again...
dyncompatibility of the trait itself is another matter. In this case, an async method makes a trait not dyn-compatible because of the implicit-> impl Futureopaque return type, as documented here.But OP didn't mention whether
dynis actually needed or not. For me,dynis almost always a crutch (exceptions exist).