Destructuring Arrays

    • Destructuring of slices of unknown length also works with patterns of fixed length.
    1. inspect(&[0, -2, 3]);
    2. inspect(&[0, -2, 3, 4]);
    3. fn inspect(slice: &[i32]) {
    4. println!("Tell me about {slice:?}");
    5. &[0, y, z] => println!("First is 0, y = {y}, and z = {z}"),
    6. _ => println!("All elements were ignored"),
    7. }
    • Show matching against the tail with patterns [.., b] and