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 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: Sep 18 2020 at 21:15UTC