1 A cast to an unsized type was attempted.
3 Erroneous code example:
6 let x = &[1_usize, 2] as [usize]; // error: cast to unsized type: `&[usize; 2]`
10 In Rust, some types don't have a known size at compile-time. For example, in a
11 slice type like `[u32]`, the number of elements is not known at compile-time and
12 hence the overall size cannot be computed. As a result, such types can only be
13 manipulated through a reference (e.g., `&T` or `&mut T`) or other pointer-type
14 (e.g., `Box` or `Rc`). Try casting to a reference instead:
17 let x = &[1_usize, 2] as &[usize]; // ok!