pub trait GenericAsyncRunner{
fn return_run_function(&self) -> ?;
}
pub enum AsyncRunError{}
pub struct SpecificAsyncRunner{}
impl SpecificAsyncRunner{
async fn run(&self) -> Result<u32, AsyncRunError> {
todo!()
}
}
impl GenericAsyncRunner for SpecificAsyncRunner {
fn return_run_function(&self) -> ? {
todo!()
}
}
I want to get a pointer to the async run
function, at runtime. In practice I'll have let generic_async_runner = Box<dyn GenericAsyncRunner>
and I want generic_async_runner.return_run_function().await
. I could downcast but in practice there will be lots of different SomethingAsyncRunner
so downcasting would have to try to downcast to all of them.
Can I rewrite async fn run() -> Result<u32, AsyncRunError>
into a desugared version that returns a Future
? In this way I can have a concrete type to put in ?
on the code above.