Replies: 1 comment 3 replies
-
So the issue was closed without comment? So sad. :-( |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Documentation says: "Here
i
doesn't need to be declared with mut since it's always going to be mutable by definition."I'd suggest to change the semantics here:
This
i
is "const" in the body of the loop, it is only allowed to be changed by thei += 2
loop increment instruction.If the programmer wants to change the loop variable within the loop body freely it must be declared with
mut
explicitly:Motivation:
Arbitrarily changing the loop variable in the loop body is considered "bad style" and allowing that makes code analysis (by compiler and human readers) much more complex. So it should be not allowed by default and enabled only if necessary.
Beta Was this translation helpful? Give feedback.
All reactions