Why does printing a pointer print the same thing as printing the dereferenced pointer?

前端 未结 2 1760
忘掉有多难
忘掉有多难 2020-11-29 09:18

From the Rust guide:

To dereference (get the value being referred to rather than the reference itself) y, we use the asterisk (*

2条回答
  •  情书的邮戳
    2020-11-29 09:37

    fn main() {
     let x = &42;
     let address = format!("{:p}", x); // this produces something like '0x7f06092ac6d0'
     println!("{}", address);
    }
    

提交回复
热议问题