Is there a function which swaps two ranges of different sizes within a slice?

Viewed 67

Swapping ranges of equal sizes can already be done with std::ptr::swap_nonoverlapping. But what about ranges of different sizes within a Vec/slice/etc.? Does such a function exist?

For example:

let mut vector = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
function_Im_looking_for(&mut vector, 1..=2, 4..=6);
assert_eq(vector, [1, 5, 6, 7, 4, 2, 3, 8, 9]);
                      _______     ____
0 Answers
Related