Closure arguments are inferred monomorphically
b8a6e9d
Opened by Eira Fransham at
Without an explicit annotation, closure arguments are inferred to have a concrete lifetime. You must manually annotate the argument in order to satisfy a HRTB.
#[derive(PartialEq)]
struct Foo;
fn use_a_foo(_: &Fn(&Foo)) {}
fn main() -> () {
// This doesn't compile
// let function = |foo_arg| {
// assert!(&foo == foo_arg);
// };
// explicit_for(&foo, &function);
// This does
let function = |foo_arg: &_| {};
use_a_foo(&function);
}
Dupe of #41078. (at least, that's the issue that seems to have received the most attention; took a bit of searching to find though!)
Michael Lamparski at 2021-09-29 20:14:59