Is there is any way to dynamically dispatching for async trait?

Defined this async trait:

pub trait Storer{
    async fn find(&self, id:String) ->Vec<Item> {

I want use like this:

async fn do_find(storer: &dyn Storer, id: String) {

Or use generic:

async fn do_find<T:Storage>(storer: T, id: String) {


But it both not works.

The second one does work.

But traits with async functions can't be dyn Traits. Use async_trait if you need that.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.