Fix `context::traits::*` unusability
If a handler is generic over a trait from context::traits
, calling any method
is currently impossible, as the compiler would emit this error:
error[E0597]: `context` does not live long enough
--> examples/location.rs:32:23
|
26 | async fn handle_location<'a, Ctx: ChatMethods<'a, C> + 'a, C: Connector>(
| -- lifetime `'a` defined here
...
32 | let call_result = context
| -^^^^^^
| |
| _______________________borrowed value does not live long enough
| |
33 | | .send_location(first_place)
| |___________________________________- argument requires that `context` is borrowed for `'a`
...
57 | }
| - `context` dropped here while still borrowed
The problem is that methods used the lifetime declared on the trait, and this made all input live longer than the context, what is practically impossible. I made lifetimes local to each method, but, to not break backwards compatibility, I left the lifetime on the traits. This lifetime should be removed in the next major version.