add ref and & test
This commit is contained in:
17
single_file_tests/ref_n_and.rs
Normal file
17
single_file_tests/ref_n_and.rs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user