On 4/21/14 7:59 AM, José Armando García Sancio wrote:
On a similar note, why did Rust decide to use the keyword "ref" when
"borrowing" in those cases and the keyword "&" when borrowing in
function arguments? Is the semantic different?
`&` in a pattern is the opposite of a reference: it *de*references in
pattern bindings.
For example
let &x = &3;
sets `x` to 3 (not `&3`).
This is for symmetry: consider that:
let (x, y) = (1, 2);
sets `x` to 1 and `y` to 2.
Because `&` is taken to destructure references, we needed another
keyword to take a reference. Hence, `ref`.
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev