You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say a variable named my_var is declared using mut keyword: mut my_var = 1 the type of my_var will be int, and currently type.nr_muls will be incremented making a regular reference and a mut reference indistinguishable using the type.is_ptr() / type.nr_muls() methods. It is still possible to achieve but a little bit convoluted and confusing.
On the next use of my_var a new identifier will be created which will point to the variable declaration, it will also set ident.is_mut if the identifier was preceded by the mut for example in cases such as:
passed as a mutable function argument
used in a mut match: match mut my_var {
mutable loop var: for mut x in items
The implementation I'm suggesting will make it much cleaner and simpler to differentiate between regular reference and mutable variables.
The text was updated successfully, but these errors were encountered:
Let's say a variable named
my_var
is declared usingmut
keyword:mut my_var = 1
the type of my_var will be int, and currentlytype.nr_muls
will be incremented making a regular reference and a mut reference indistinguishable using thetype.is_ptr()
/type.nr_muls()
methods. It is still possible to achieve but a little bit convoluted and confusing.On the next use of
my_var
a new identifier will be created which will point to the variable declaration, it will also setident.is_mut
if the identifier was preceded by themut
for example in cases such as:mut
match:match mut my_var {
for mut x in items
The implementation I'm suggesting will make it much cleaner and simpler to differentiate between regular reference and mutable variables.
The text was updated successfully, but these errors were encountered: