I'm trying to store a function in a struct:
trait T<'a> {}
struct A {}
struct B<'a> {
a: &'a A
}
impl<'a> T<'a> for B<'a> {}
fn f1<'a, E: T<'a>>(a: &'a A) {}
struct D {
f: fn(&A)
}
fn main() {
let d = D { f: f1::<B> };
}
The compiler complains:
error[E0308]: mismatched types
--> src/main.rs:18:20
|
18 | let d = D { f: f1::<B> };
| ^^^^^^^ expected concrete lifetime, found bound lifetime parameter
|
= note: expected type `fn(&A)`
= note: found type `fn(&A) {f1::<'_, B<'_>>}`