Closed peterstuart closed 2 years ago
You need to write this as:
#[async_trait]
pub trait Create<Input, Store, Error>
where
Self: Sized,
Store: Send + Sync,
{
async fn create(input: Input, store: Store) -> Result<Self, Error>
where
Store: 'async_trait;
}
…
#[async_trait]
impl<'a> Create<Input, &'a PgPool, Error> for User {
async fn create(input: Input, store: &'a PgPool) -> Result<Self, Error>
where
'a: 'async_trait,
{
…
}
}
Perfect, thanks for the help!
In the following example, I'd like implementations of the
Create
trait to be able to haveStore
be either a reference or a mutable reference, so I don't want to bake that in to the definition of the trait.… but when I try to write an implementation using a reference:
… I get the following error:
Is it possible to achieve what I'm trying to do?