Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let x = &mut 5;
- //let y = &x;
- let y = &x;
- //*x = *x + 1;
- // y = is address where x is stored
- // y* = x = value of x = address where 5 is stored
- // y** = x* = 5 = literal i32 value 5
- **y = **y + 5; // Giving compile error "error: cannot assign to data in a `&` reference"
- println!("{:p}", y); // 0x7fff230091e8
- println!("{:p}", *y); // 0x7fff230091e4
- println!("{:p}", x); // 0x7fff230091e4
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement