I'm banging my head against #Rust borrow checker. If somebody can save my brain that would be cool.
@kmk Remove the 'a in fn data_source like this: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=95abc8dad2ca69890b4894f3547f9471
@teromene That works for the trait. But now I can not implement it for Postgres (the second link in the question): error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2880ba2804aefb47685983e13403b3b0)
@kmk Well now you can overshadow it:
@teromene I don't get it: your example works because you have not put in the `generate` generic function. If I put it back in, it does not compile: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=df5fc7fe86a359ed5a88cdbd9b701af4
@kmk Sorry, didn't see your message.
The problem you have here is that you have a cyclic dependency on lifetimes:
You need to get the source, which borrows self for a.
Then, with the source, you call another function that must act on a, but self is already borrowed. You will need to make an allocation somewhere or use a "dynamic" borrow tool like an Rc
@teromene And can't I limit the trait enough that it will fit like the "real" objects?
@kmk One of the thing you could do is to remove the `postgres::Transaction<'a>` and to replace it with a getter.
You would then be able to get it matching your local lifetime scope
Le réseau social de l'avenir : Pas d'annonces, pas de surveillance institutionnelle, conception éthique et décentralisation ! Possédez vos données avec Mastodon !