Can someone explain, why a Vec<T>
to &[T]
works without boilerplate code?
fn main() {
let v = vec![10, 20, 30];
let f = first(&v); // why does this conversion from `Vec` to `&[]` work?
println!("first of {v:?} is {f:?}");
}
fn first(slice: &[u32]) -> Option<u32> {
slice.get(0).copied()
}