Skip to content

async_trait incompatible with builder-pattern #28

@clotodex

Description

@clotodex

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions