Q:

What's the correct way to specify that a function takes an array of unspecified length as an argument?

Here's a working selection sort I've implemented in Rust along with a simple print function using &mut [i32]:
fn print_nums(nums: &mut [i32]) {
    println!("{:?}", nums);
}

fn selection_sort(nums: &mut [i32]) {
    let len = nums.len();
    let mut mindex;

    for i in 0..len {
        mindex = i;
        for j in (i + 1)..len {
            if nums[j] < nums[mindex] { mindex = j; }
        }
        nums.swap(i, mindex);
    }
}

fn main() {
    let mut xs: [i32; 5] = [1, 2, 3, 4, 5];
    selection_sort(&mut xs);
    print_nums(&mut xs);
}

&mut [i32] seems reasonable for selection_sort since it modified the array, but it doesn't seem appropriate to use for print_nums: I just couldn't figure out another way to get the types to match. :P

A:

You can just use &[u32]. No need to add mut modifier because you're not modifying data in print method.
fn print_nums(nums: &[i32]) {
    println!("{:?}", nums);
}

print_nums(&xs);

