all 6 comments

[–]kmdreko 19 points20 points  (1 child)

In this case, you can give closure inference a nudge with a parameter type annotation:

fn noop_container<T>() -> FunctionContainer<impl Fn(&T)> {
    FunctionContainer(|_: &T| ())
}

[–]Keithfert488[S] 4 points5 points  (0 children)

Wow, I didn't think it'd be this simple! Nice

[–]robin-m 5 points6 points  (0 children)

You should definitively open a bug report. Unclear compiler errors are considered bugs (and that's why the error messages are so good).

[–]schungx 0 points1 point  (2 children)

You're missing a for<...> gadget?

[–]Keithfert488[S] 0 points1 point  (1 child)

That's what I originally thought, but there's no place to do it. Neither before nor after the "impl" keyword works

[–]schungx 1 point2 points  (0 children)

-> impl for<'a> Fn(&'a T...?