News for hackers. Stuff that matters.
Re:Should Small Rust Structs be Passed by-copy or by-borrow? by db48x on Saturday December 31, 2022 @08:12PM (#34202536)
That kind of problem doesn't happen in Rust though, because if all you have is a reference then you cannot mutate anything. You can only mutate things if you have a mutable reference to them, which makes the caller jump through hoops to acquire one for you. They may have to have ownership of the thing, or use a Mutex or RWLock to acquire exclusive access to it, before they can call your method. Nothing can be mutated by accident, or in a surprising place.

There are no comments on this comment yet.