Stream: t-compiler/help

Topic: borrow checking for struct fields


Andrey Rublev (May 12 2019 at 20:24, on Zulip):

Is it possible, maybe in future, to have distinct borrow checking for structure fields, not for entire struct ? In this example https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=9c68eb5099baf17c943fadd9d8ca6cb1 compiler complains because there are mutable and immutable borrows, but in fact there is immutable borrow for self.string and only "state" field is changed in "mutate" method. Error is easily can be avoided if I move immutable borrowing of self.string inside "mutate" method, but sometimes this approach may not be convenient.

nikomatsakis (May 13 2019 at 17:43, on Zulip):

it's possible yes, but it will require changes to the language.

Last update: Nov 11 2019 at 23:00UTC