[Rust] ref keyword for borrow value
https://doc.rust-lang.org/std/keyword.ref.html
struct Point {
x: i32,
y: i32,
}
fn main() {
let y: Option<Point> = Some(Point { x: 100, y: 200 });
match y {
Some(ref p) => println!("Co-ordinates are {},{} ", p.x, p.y), // have to use ref keyword to borrow the value
_ => panic!("no match!"),
}
y; // after using ref, you can borrow the value y.
}