Check out example codes for "rust swap vector elements". It will help you in understanding the concepts better.

Code Example 1

fn main() {
    let mut numbers = vec![1, 2, 3];
    println!("before = {:?}", numbers);
    numbers.swap(0, 2);
    println!("after = {:?}", numbers);
}

Learn ReactJs, React Native from akashmittal.com