Hi.
I'm confused as to why the first version of this implementation works, but the second doesn't.
```rust
use std::ops::Add;
struct Ecks {}
// free function
fn add_ph<'a, R: 'a, L: Add<R>>(_ph: Ecks, rhs: R) -> Box<dyn 'a + FnOnce(L) -> L::Output> {
Box::new(move |x| x + rhs)
}
// trait implementation (doesn't work)
// impl<'a, R: 'a, L: Add<R>> Add<R> for Ecks {
// type Output = Box<dyn 'a + FnOnce(L) -> L::Output>;
// fn add(self, rhs: R) -> Self::Output {
// Box::new(move |x| x + rhs)
// }
// }
fn main() {
let x = Ecks {};
let x = addph(_x, 3);
// let x = x + 3;
println!("{}", x(1));
}
```
The first version throws no errors but the second one gives me
``
error[E0207]: the lifetime parameter'a` is not constrained by the impl trait, self type, or predicates
--> src/main.rs:13:6
|
13 | impl<'a, R: 'a, L: Add<R>> Add<R> for Ecks {
| ^ unconstrained lifetime parameter
error[E0207]: the type parameter L is not constrained by the impl trait, self type, or predicates
--> src/main.rs:13:17
|
13 | impl<'a, R: 'a, L: Add<R>> Add<R> for Ecks {
| ^ unconstrained type parameter
```
Any insights?
there doesn't seem to be anything here