dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.81k stars 84 forks source link

Per-method `+ Send`? #131

Closed nazar-pc closed 1 year ago

nazar-pc commented 3 years ago

I have a trait where I have to use #[async_trait(?Send)] because of some methods and data structures they return, but at the same time I want boxed future to be Send when returned from other methods.

Do you think it would be valuable to have an additional per-method attribute that would add + Send?

It is possible to work around by writing a method that returns Pin<Box<dyn Future<Output = ()> + Send + '_>> manually, but cleaner approach would be beneficial I think.

dtolnay commented 1 year ago

I would prefer not to build this into this crate. But it would be reasonable for somebody else to maintain a more fully featured macro for async traits that handles this use case.