builder-pattern icon indicating copy to clipboard operation
builder-pattern copied to clipboard

async_trait incompatible with builder-pattern

Open clotodex opened this issue 2 years ago • 0 comments

I cannot get async_trait and builder-pattern to play nice together.

My test (assume MyAsyncTrait exists):

#[derive(Builder)]
pub struct MyStruct {
    a: SomeStructA,
    b_provider: Box<dyn MyAsyncTrait>,
}

It complains that MyAsyncTrait cannot be made into an object. My guess is that either the double-code generation breaks something OR that builder-pattern would need to place the #[async_trait] in its generated code too.

This is currently blocking me from using the builder pattern.


If this is too hard to implement, Rust aims to support a first version of stable async traits (not via library) from 1.74, which should land in July. Then this might be resolved. What do you think?

clotodex avatar May 15 '23 19:05 clotodex