&[i32;_]
is a borrow of an array, while &[i32]
is a slice, which means a dynamically sized array or a part of an array.
&[i32;_]
means that the borrowed array has a statically known size _
which means the size is statically inferred (which must be 2 but not detailly shown by rust-analyzer), by the the item count of the given initializer [1, 2]
.
&[i32]
means that it is a slice, which does not have a known size at compile time, and it is dynamically sized at runtime.
&[i32;_]
is a thin pointer which means the actual memory layout of &[i32;_]
is just a raw usize
pointer to the starting position of the array.
&[i32]
is a fat pointer which means the actual memory layout of &[i32]
is made of 2 usize
s. One is the raw pointer to the starting position of the slice, and the other one is the length of the slice.