Deref
We'll cover the following...
We'll cover the following...
Alright, I’m tired of fruit. Let’s talk about plain old numbers again. Consider this program that only uses mutable variables, no references:
Press + to interact
Rust 1.40.0
fn main() {let x: i32 = 5;let mut y: i32 = 6;y -= 1;assert_eq!(x, y);println!("Success");}
What this means is: create a new immutable variable, x
, that holds 5. Then create a mutable variable, y
, that holds 6. Subtract 1 from y
...