pubfninsert_sort<T:PartialOrd>(src:&mutVec<T>){
let length = src.len();for i in1..length {
for j in(1..=i).rev(){
if src[j]< src[j-1]{
src.swap(j, j-1);}else{
break;}}}}#[cfg(test)]modtests{
……
#[test]fninsert_sort_test(){
letmut num =vec![7,1,5,4,1,8,11];select_sort(&mut num);assert_eq!(num,[1,1,4,5,7,8,11]