Closed cmcaine closed 1 year ago
This says that Rust frees and then allocates new larger memory. Perhaps it should say that Rust allocates a larger chunk of memory, writes "Ferris Jr." and then frees the first allocation?
https://github.com/cognitive-engineering-lab/rust-book/blob/d2af51055890d1d3611d3714f9b5a6a087f75dfe/src/ch04-01-what-is-ownership.md?plain=1#L276
Besides, isn't the exact behaviour an implementation detail of String?
Thanks for the issue, I've clarified the order of operations.
This behavior is an implementation detail of string, but it is relevant to understanding memory safety.
This says that Rust frees and then allocates new larger memory. Perhaps it should say that Rust allocates a larger chunk of memory, writes "Ferris Jr." and then frees the first allocation?
https://github.com/cognitive-engineering-lab/rust-book/blob/d2af51055890d1d3611d3714f9b5a6a087f75dfe/src/ch04-01-what-is-ownership.md?plain=1#L276
Besides, isn't the exact behaviour an implementation detail of String?