array: &mut[i32] is a mutable borrowed pointer - that is, you can mutate the array value that it’s pointing to. On the other hand you can’t mutate the pointer itself. The following code, for instance, doesn’t compile, because the last line tries to assign a new value to a:
let mut b = 4;
let a: &mut i32 = &mut 3;
a = &mut b;
But if you change the second line to
let mut a: &mut i32 = &mut 3; then everything’s fine.
It looks like the probjem in your code is actually not the function declaration, it’s the line
reverse(&mut array, lo+1, hi-1);.
array has type
&mut [i32]. When you do
&mut array the result is a mutable pointer to the pointer
array, which has type
&mut &mut [i32]. Because
array is immutable the compiler can’t create a mutable reference to it. Change that line to
reverse(array, lo+1, hi-1); and everything’s fine.
I’m really surprised that you can pass an
&mut &mut T to a function taking an
&mut T, though.