I have a trait defined like this:
trait MyTrait {
async fn my_async_fn(arg: SendType) -> Result<Self, Box<dyn Error>>;
}
How do make the future returned by my_async_fn be Send for everything that Implements the trait?
I have a trait defined like this:
trait MyTrait {
async fn my_async_fn(arg: SendType) -> Result<Self, Box<dyn Error>>;
}
How do make the future returned by my_async_fn be Send for everything that Implements the trait?
On
You can use crate async_trait and just return type without Future
#[async_trait::async_trait]
trait MyTrait {
async fn my_async_fn(arg: SendType) -> Result<Self, Box<dyn Error>>;
}
If you will make the trait public the compiler will help you:
So: