At least the last time I cared about this, the borrow checker wouldn't allow mutable and immutable borrows from the same underlying object, even if they did not overlap. (Which is more restrictive, in an obnoxious way.)
At least the last time I cared about this, the borrow checker wouldn't allow mutable and immutable borrows from the same underlying object, even if they did not overlap. (Which is more restrictive, in an obnoxious way.)
https://godbolt.org/z/YhGajnhEG
It's mentioned later in the same article you shared above.
fn f() {
let mut v = vec![1, 2, 3, 4, 5];
let (header, tail) = v.split_at_mut(1);
b(&header[0], &mut tail[0]);
}> split_at_mut is just unsafe code (and sibling comment mentioned it hours before you did). The borrow checker doesn't natively understand that.
Is creating a TCP socket using stdlib functions unsafe? How about writing to a file? Or acquiring a mutex?
I would suggest doing some more reading before chiming in here :)
Easier to lose context with longer comment chains...