3 ms·
This is a good example. Another common situation is a struct that has both `foo` and `bar` members and then exposes both `.get_foo_mut()` and `.get_bar_mut()`.
by oconnor663 4y ago
This is a good example. Another common situation is a struct that has both `foo` and `bar` members and then exposes both `.get_foo_mut()` and `.get_bar_mut()`. (Again this is a trivial example, and maybe in the real world they do more work before returning those references.) The problem is that it's illegal to call either of those while the return value from the other is still alive. Even though we know they don't alias each other, and we could totally accomplish the same thing if the members were public, there's no way for the method signatures to express what parts of the struct they don't touch.
- alkonaut 4y agoI think there is work going on in this area (borrowing parts of structs)? Might have dreamt.