Nice discussion! I would point out that you can also stop a variable from being mut by shadowing its binding:
// `values` is mutable so that we can add to itletmutvalues=vec![];foriin1..10{values.extend(vec![i;i]);}letvalues=values;// `values` is no longer mutable
I agree that using a block seems more elegant, but like using drop(), this avoids a level of indentation.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice discussion! I would point out that you can also stop a variable from being
mut
by shadowing its binding:I agree that using a block seems more elegant, but like using
drop()
, this avoids a level of indentation.