Comment by loeg
1 day ago
Not exactly -- independent subranges of the same range (as would be relevant to something like memcpy/memmove/strcpy). E.g.,
https://godbolt.org/z/YhGajnhEG
It's mentioned later in the same article you shared above.
1 day ago
Not exactly -- independent subranges of the same range (as would be relevant to something like memcpy/memmove/strcpy). E.g.,
https://godbolt.org/z/YhGajnhEG
It's mentioned later in the same article you shared above.
split_at_mut is just unsafe code (and sibling comment mentioned it hours before you did). The borrow checker doesn't natively understand that.
It is safe btw. The difference is that it returns two mutable references vs. one shared ref and one mutable ref. But as they noted, a mutable ref can always be “downgraded” into a shared ref.
Gotcha. There is a split_at_mut method that splits a mutable slice reference into two. That doesn’t address the problem you had, but I think that’s best you can do with safe Rust.
Yeah. It just isn't something the borrow checker natively understands.