Description of the problem: In the section that teaches copying as a possible solution to ownership errors, the copying is done via join. From the explanation
However, the clone copies every string in the input. We can avoid unnecessary copies by adding the suffix later:
it may be unclear to the beginner that the vector clone is not needed only because join already copies.
Suggested fix: Something like
However, the join already clones the strings inside the vector into a new string using an immutable reference to the vector. Therefore, cloning the vector beforehand is not necessary. We can add the suffix afterwards:
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#fixing-an-unsafe-program-not-enough-permissions
Description of the problem: In the section that teaches copying as a possible solution to ownership errors, the copying is done via
join
. From the explanationit may be unclear to the beginner that the vector clone is not needed only because
join
already copies.Suggested fix: Something like
may explain what is happening more clearly.