Re:Fast Rust Builds
by MathiasPius on Monday September 06, 2021 @04:51AM
(#28431725)
It's so that a reader of the calling code can immediately reason about which calls might be mutating state. If you have 10 calls, all taking &bytes, any of which may or may not be mutating the data while others are merely reading it, it becomes very difficult to reason about.
By being explicit about this, Rust becomes easier to read, but (slightly) harder to write.
Re:Fast Rust Builds
by zozbot234 on Monday September 06, 2021 @05:32AM
(#28431950)
Shared borrows and unique borrows also behave very differently in Rust. '&mut' for unique borrows is a bit of a misnomer, because passing some objects via a shared '&' reference might also mutate state 'indirectly' via internal mutability.
By being explicit about this, Rust becomes easier to read, but (slightly) harder to write.