error: lifetime may not live long enough
--> src/main.rs:83:44
|
83 | let func = |data: &(u8, u16)| -> &u8 { &data.0 };
| - - ^^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | let's call the lifetime of this reference `'2`
| let's call the lifetime of this reference `'1`
It expected the return type of the closure to be &'a u8 to be moved into Closure but it instead found &u8, so some other anonymous references &'_ u8. I suspect I need to figure out how to type annotate let func in the case of an unboxed closure to specify the same lifetimes that I made in the boxed version?
Only works with explicitly typed variable. I only know how to make a boxed closure explicitly typed on a variable, not an unboxed one. Inference just isn't working for the let binding case. I have to bind it to a struct field or a function call param directly.