These are chat archives for rust-lang/rust

22nd
Apr 2018
xliiv
@xliiv
Apr 22 2018 18:14
I encountered such case https://play.rust-lang.org/?gist=f840f82c63de6e500a011c702380eea2&version=stable and i'm wondering if this should be improved somehow?
perhaps i made it a bit ridicoules (compering to the original code) when i tried to minify it..
Denis Lisov
@tanriol
Apr 22 2018 19:26
@xliiv There are some problems with fixing this... you would need to somehow annotate get_value_mut to indicate that it only borrows self.value and not other fields. AFAIK, there's no plan about this yet.
xliiv
@xliiv
Apr 22 2018 19:30
@tanriol i'm not sure how other rustaceannanes (sorry, don't know spelling :) ) handle that, but i thought that whould be nice ownership2.0 or something.. i mean increasing granularity.. current version is safe because is generic, but in some level of details... borrow-chceckers bans legal things (i aware that is probabbly limited by developing time since is much more demanding)..
Denis Lisov
@tanriol
Apr 22 2018 19:34
Even the desired outcome itself is non-obvious here. For example, would you expect to explicitly annotate which fields are borrowed or to have them inferred from the function body? This is an important part of the API, so I'd expect it to be explicit.
This change will also limit the refactoring significantly as making any pair of methods have conflicting borrows if they were not conflicting before would be formally a breaking change... even if no one uses that particular pair and it makes little sense.
Furthermore, if you choose annotating methods, there's a problem of what exactly do these annotations tell. For example, if all fields are private, how would you expect the annotations to look?
xliiv
@xliiv
Apr 22 2018 20:13
@tanriol i didn't think it throught, although at the first sight it's a bit odd that you get all or nothing..