I’m wondering why `f2`

and `f3`

in `main()`

below need a type annotation to compile but `f1`

does not? Is there any way to avoid the requirement of the type annotation in this trait?

```
struct C<T> {
data : T
}
trait MyTrait<TIn, F, TOut>
where
F: Fn(TIn) -> TOut,
{
fn g(x: Self, f: F) -> TOut;
}
impl<TIn, F, TOut> MyTrait<TIn, F, TOut> for C<TIn>
where
F: Fn(TIn) -> TOut,
{
fn g(x: C<TIn>, f: F) -> TOut {
println!("1");
f(x.data)
}
}
impl<TIn, F, TOut> MyTrait<&TIn, F, TOut> for &C<TIn>
where
F: Fn(&TIn) -> TOut,
{
fn g(x: &C<TIn>, f: F) -> TOut {
println!("2");
f(&x.data)
}
}
impl<TIn, F, TOut> MyTrait<&TIn, F, TOut> for C<TIn>
where
F: Fn(&TIn) -> TOut
{
fn g(x: C<TIn>, f: F) -> TOut {
println!("3");
f(&x.data)
}
}
fn main() {
let x1 : C<u32> = C{data : 1};
let x2 : C<u32> = C{data : 2};
let x3 : C<u32> = C{data : 3};
let f1 = |x| x;
let f2 : fn(&u32) -> u32 = |&x| x;
let f3 : fn(&u32) -> u32 = |&x| x;
let y1 = MyTrait::g(x1, f1);
let y2 = MyTrait::g(&x2, f2);
let y3 = MyTrait::g(x3, f3);
}
```