Ref Keyword in Rust

The ref keyword in Rust bind a variable by reference during pattern matching.

Unlike &, which expect the pattern itself to be a reference, ref only bind the value to a reference.

ref on the left side of = is the same as & on the right.

let ref x = 1;
let x = &1;

& on the left side of = is the same as * on the right.

let &y = x;
let y = *x;

tags:PatternMatchingPatternMatching