Closed cagatay-y closed 8 months ago
Ah great catch! I had originally written this using split_at_mut
(which does actually use unsafe), and then thought "hmm well it would be simpler to just use split_first_mut
. But of course, that's a special case that reduces to pattern matching :| I will revert the section to use split_at_mut
.
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch04-03-fixing-ownership-errors.html?search=#fixing-a-safe-program-mutating-different-array-elements
Description of the problem: The book explains that split_first_mut works using unsafe, which as far as I understand is not the case (since 2020 based on git blame).
Suggested fix: This explanation cannot simply be removed, since it is used as a segue to explain the occasional necessity of unsafe blocks. I don't know what would be better example to make the case for unsafe blocks in this case.