buldak 0.28.1

It is a library that provides various sorting functions.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::cmp::Ordering;
use std::mem;

pub fn swap<T>(x: &mut [T], i: usize, j: usize) {
    let (lo, hi) = match i.cmp(&j) {
        // no swapping necessary
        Ordering::Equal => return,

        // get the smallest and largest of the two indices
        Ordering::Less => (i, j),
        Ordering::Greater => (j, i),
    };

    let (init, tail) = x.split_at_mut(hi);
    mem::swap(&mut init[lo], &mut tail[0]);
}