29 lines
362 B
Rust
29 lines
362 B
Rust
|
|
|
|
// 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);
|
|
|
|
let s = "S".to_owned();
|
|
|
|
|
|
match &s {
|
|
ss => println!("{}", ss),
|
|
}
|
|
|
|
match s {
|
|
ref ss => println!("{}", ss),
|
|
}
|
|
}
|
|
|