-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
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);
}
oxalica
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.