add ref and & test

This commit is contained in:
2020-04-17 08:18:26 +08:00
parent 11e332e30f
commit d532226133

View File

@@ -0,0 +1,17 @@
// ref: https://users.rust-lang.org/t/ref-keyword-versus/18818/4
fn main() {
let ref x = 1;
let x2 = &1;
let &y = x;
let y2 = *x2;
println!("{} {}", x, x2);
println!("{} {}", y, y2);
}