async-recursion icon indicating copy to clipboard operation
async-recursion copied to clipboard

Support for traits

Open a-tal opened this issue 1 year ago • 1 comments

Hey,

First, thanks for the crate, it's great. I'm wondering if it should be able to support trait methods?

Maybe I'm just doing something wrong... and I was able to move things around for now so I can still use this, but I thought I'd put it out there to see if anyone else was running into this issue.

Sorry I haven't looked into macros enough to actually submit a patch, but here's a test case which errors (based on a copy/paste job of the struct tests)

a-tal avatar Feb 29 '24 17:02 a-tal

It should be possible, but this crate was implemented before async fn in traits were stabilized. I'll do some investigations, but in the mean time https://github.com/dtolnay/async-trait (which boxes async trait methods) should allow you to recurse.

Given the overlap, the correct solution may just be adding documentation recommending async-trait for use w/ async fn in traits.

dcchut avatar Mar 04 '24 06:03 dcchut