Hi!
Now that support for async functions in traits might be coming in the near future I've been trying to use the nightly implementation to add async support to my crate but I've been facing the following issue.
Minimal reproducible example (playground link):
#![feature(async_fn_in_trait)]
trait IntoStateMachine {
type Context<'a>;
}
trait State<M> where M: IntoStateMachine {
async fn handle(&mut self, context: &mut M::Context<'_>);
}
struct MyStateMachine;
struct MyState;
impl IntoStateMachine for MyStateMachine {
type Context<'a> = ();
}
impl State<MyStateMachine> for MyState {
async fn handle(&mut self, context: &mut ()) {}
}
fn main() {
println!("Hello, world!");
}
Gives the following error:
error[E0195]: lifetime parameters or bounds on method `handle` do not match the trait declaration
--> src/main.rs:19:20
|
8 | async fn handle(&mut self, context: &mut M::Context<'_>);
| - lifetimes in impl do not match this method in trait
...
19 | async fn handle(&mut self, context: &mut ()) {}
| ^ lifetimes do not match method in trait
I don't really understand what the issue is here or how I might resolve it?
Thanks!