Quick sort implemented in Rust
Your implementation is incorrect. It fails for all sorts of inputs, but the simplest is 

let mut array = [0, 0];
quicksort(&amp;mut array, 0, 1);

Figuring out how to even call quicksort is overly complicated. Why do I have to pass in these numbers; can't the code figure that out?
Run rustfmt. It will automatically tell you things like:


&amp;mut[T] should be written as &amp;mut [T].

Run clippy.  It will automatically tell you things like:


Not to use return at the end of a function.
That you can use a += b instead of a = a + b
That you've re-implemented slice::swap





Since the code doesn't work, I don't know that the transforms I made preserve the existing behavior. The rest is caveat emptor.


You have redundant type declarations. You don't need to say let x: T = y as T, just let x = y as T.
You also don't often need to specify the type at all, type inference can handle it.
Presumably you converted to an isize because you were subtracting one from zero. Instead, increase the values by one to keep it in the range of a usize. To transform, add one to the initial value of i and subtract one from the usages of i, then remove the casts and simplify the math.




fn partition(array: &amp;mut [isize], first: usize, last: usize) -&gt; usize {
    let pivot = array[last];

    let mut i = first;
    let mut j = first;

    while j &lt; last - 1 {
        if array[j] &lt; pivot {
            array.swap(i, j);
            i += 1;
        }
        j += 1;
    }

    if array[last] &lt; array[i] {
        array.swap(i, last);
    }

    i
}