I have this code:
lambda: &(dyn for<'b> Fn(
PlayerCreateLambdaArgs<'b>,
) -> Pin<Box<dyn Future<Output = Result<DomainPlayer, String>> + Send + 'b>>
+ Sync
+ '_)
and I would like to create a type for lambda to use it like:
lambda: &Lambda<'_, PlayerCreateLambdaArgs<'a>, DomainPlayer>,
pub type Lambda<'a, Args, Res> = dyn for<'b> Fn(Args<'b>) -> Pin<Box<dyn Future<Output = Result<Res, String>> + Send + 'b>> + Sync + 'a;
but I'm getting this error:
error[E0109]: lifetime arguments are not allowed on type parameter `Args`
--> src/main.rs:56:54
|
56 | pub type Lambda<'a, Args, Res> = dyn for<'b> Fn(Args<'b>) -> Pin<Box<dyn Future<Output = Result<Res, String>> + Send + 'b>>
| ---- ^^ lifetime argument not allowed
| |
| not allowed on type parameter `Args`
|
note: type parameter `Args` defined here
--> src/main.rs:56:21
|
56 | pub type Lambda<'a, Args, Res> = dyn for<'b> Fn(Args<'b>) -> Pin<Box<dyn Future<Output = Result<Res, String>> + Send + 'b>>
| ^^^^
error[E0582]: binding for associated type `Output` references lifetime `'b`, which does not appear in the trait input types
--> src/main.rs:56:62
|
56 | pub type Lambda<'a, Args, Res> = dyn for<'b> Fn(Args<'b>) -> Pin<Box<dyn Future<Output = Result<Res, String>> + Send + 'b>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some errors have detailed explanations: E0109, E0582.
For more information about an error, try `rustc --explain E0109`.
How can I allow lifetime args on type parameter Args
?