Different types even though same value assigned

31 views Asked by At

I am having hard time wrapping my head around types and references in rust. For eg., I have this code:

let my_arr = [3, 5, 4, 88, 77];
let my_slice1 = &my_arr;
let my_slice2: &[i32] = &my_arr;

IDE suggests my_slice1 is of type &[i32, 5] ie reference type to array of type [i32, 5].

If this suggestion is correct, then my_slice1 and my_slice2 are of different types even though they have been assigned same value(&my_arr).

Is some implicit conversion happening for my_slice2?

0

There are 0 answers