Closed
Description
I tried this code:
fn main() {
let mut v = vec![1, 2, 3];
let head = {
std::mem::replace(&mut v, v.split_off(1))
};
}
I expected to see this happen: all good.
Instead, this happened: error: cannot borrow
v as mutable more than once at a time
If I rewrite this code onto
fn main() {
let mut v = vec![1, 2, 3];
let head = {
let t = v.split_off(1);
std::mem::replace(&mut v, t)
};
}
then all be nice.