&x only appears directly on a call argument, to pass x to a var parameter so the callee
can change it. It isn't a reference or address-of operator, and it needs something assignable.
Wrong#
fn main() {
var xs = [1]
let ys = &xs
print(ys)
}Fixed#
fn main() {
var xs = [1]
let ys = xs
print(ys)
}Common causes#
- Taking a reference as in Rust or C++: Auk copies values cheaply (copy-on-write).
&on something that isn't a variable, field or index:f(&g()).&for logical and: write&&.