Re:Thoughts on Rust, a few thousand lines in
by UK-Al05 on Wednesday January 09, 2019 @04:15PM
(#18868968)
You can't mutate variables in rust without declaring mut
[ Parent
| on HN ]
Re:Thoughts on Rust, a few thousand lines in
by StreamBright on Wednesday January 09, 2019 @04:19PM
(#18869006)
But how do you know just by reading that code? It would not be obvious to me at all.
Re:Thoughts on Rust, a few thousand lines in
by bryal on Wednesday January 09, 2019 @04:28PM
(#18869091)
I think it's quite fine to assume the reader knows enough rust to know the difference between mutable and immutable variables.
Re:Thoughts on Rust, a few thousand lines in
by empath75 on Wednesday January 09, 2019 @04:36PM
(#18869181)
let foo = bar;
let foo = bat;
is shadowing
let foo = bar; foo = bat;
is a compilation-time error because foo isn't mutable.
let mut foo = bar; foo = bat;
is reassignment.
in working code, either foo is declared as mutable or it's not, and it's pretty obvious from the code what's happening.
Re:Thoughts on Rust, a few thousand lines in
by StreamBright on Wednesday January 09, 2019 @05:12PM
(#18869507)
I guess. I would just never write code like that.
Re:Thoughts on Rust, a few thousand lines in
by goto11 on Wednesday January 09, 2019 @04:25PM
(#18869061)
You mean if you don't know the language?
Re:Thoughts on Rust, a few thousand lines in
by StreamBright on Wednesday January 09, 2019 @05:12PM
(#18869503)
I guess I just need to learn Rust. I wouldn't write a style of code where I have 3 lets after an other and using the same variable name.