-
We have a type T where: T has Drop. T does NOT have clone/copy.
-
We have
ans : Vec<T>, andans.len() = 100 -
Is there a way to perform the following operation:
drop ans[3];
ans[3] = ans[99];
ans.len() = 99;
We have a type T where: T has Drop. T does NOT have clone/copy.
We have ans : Vec<T>, and ans.len() = 100
Is there a way to perform the following operation:
drop ans[3];
ans[3] = ans[99];
ans.len() = 99;
This is Vec::swap_remove, I believe. The drop will occur when the returned value goes out of scope, so not strictly in the order you listed...
swap_remove is indeed what I want. Thanks!