Let's say I have such a function:
fn take_by_ref(i:&i32){
println!("{}",i);
}
Now I want to pass mutable reference there:
#[test]
fn test_mut(){
let mut x = 9;
let m = &mut x;
}
And it is unclear what is the difference between the two calls to this function?
first:
take_by_ref(m);
second:
take_by_ref(&*m);
Are these two calls equal and the compiler makes first call as the second one automatically? or is there a difference?
And won't the rule that either mut reference or immutable can exist be violated here when call take_by_ref
?
That is, the question is that when passing a mut
variable to such a function, it can become auto-immutable?