:nerd_face: Dereference is done only to a referenced variable
:nerd_face: A variable is automatically referenced when & is used during assignment
:nerd_face: A variable can also be a reference by using the key word ref
// here the variable myref is automatically a reference
// by the virtue of &
let myref = &10;
// to test it write following code
match myref {
&val => println!("auto referenced variable {}", val),
}
// dereference is possible only when the variable is a reference
// deference is done via *
match *myref {
val => println!("auto referenced variable once more {}", val)
}
:nerd_face: Dereference is done only to a referenced variable :nerd_face: A variable is automatically referenced when & is used during assignment :nerd_face: A variable can also be a reference by using the key word
ref