Use of ref, must, & in let statements

See this Reddit thread:

let a = &y;
let b = &mut y;
let mut c = &y;
let mut d = &mut y;

Are semantically equivalent to:

let ref a = y;
let ref mut b = y;
// let mut ref c = y;     // Not valid
// let mut ref mut d = y; // Not valid

In all cases, the first examples should be preferred. To put another way, use of ref should be reserved for pattern matching. (Alternatively, as per this RFC removing ref would do the trick).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.