编辑代码

fn main() {
    let mut r_list = [5,1,7,2,8,9,3];

    let r_len = r_list.len();

    for i in 0..r_len {
        println!("i: {}-{}", i, r_list[i]);

        let mut min = i;

        for j in i+1..r_len {
            println!("j: {}-{}", j, r_list[j]);
            if r_list[j] < r_list[min] {
                min = j;
                println!("min: {}", min);
            }
        }

        if min != i {
            println!("swap: {}-{}", i, min);
            r_list.swap(i, min);
        }

    }

    println!("finish {:?}", r_list);
}