LYR-PAR0058
'&' before a lambda parameter's pattern
A lambda parameter written as a pattern in parentheses carries the place mark &: (&(a, b)) => ….
Explanation
&n makes a parameter take the caller's place, which is one named thing. A pattern takes the value apart into new bindings; there is no single place it could stand for.
Take the place with a name, (&p) => …, or take the value apart without the mark.
Wrong
fn main(): void {
let f = (&(a, b)) => a;
}
Right
fn main(): void {
let f = ((a, b): (int, int)) => a + b;
let _ = f((1, 2));
}