fn main() {
let mut a:Vec<i64> = Vec::new();
println!("{:?}", a.to_owned());
let b = &mut a;
(*b).push(1); // works b.push(1); also (without *)
println!("{:?}", b);
drop(b);
println!("{:?}", a);
let mut c = 1;
let d = &mut c;
*d += 1; // why is * needed in this case?
drop(d);
println!("c={}",c);
}
In the code, when using vector, .push()
works with * or without *.
But when using integer, * is necessary.
How could I determine to use or not * when modifying an object?