Thank you for your reply. Immutable variable bindings by default are one of the big attractions of Rust for me, and I use them extensively. However, immutable variable bindings can be shadowed, and
const are not; one definition, one value. Likewise it prevents one creating a variable binding to something of the same name. This is good and bad; it depends on what one is trying to achieve.
Why would one want to use a
const in a function? In this case, this was a single unit test. The scope of some of the test data was that test case. It was invariant. It was also, like most good test data, not something that should be the result of complex calculation, time of day, etc - ie always reproducible and simple to understand.
const seemed to express that purpose.
const b producing a warning - I am aware that it does with the default warnings
rustc uses, but the code I’ve written up above was intended as a simplification. As it happens, one can’t rely on those. As Rust develops, house styles will evolve - and the current Pythonesque style won’t suit everyone (indeed, I’d go further and suggest it’s actually an anti-style for some people, due to the way they read and process written information - myself included; an area of study that I’d like to do a paper on one day if the time and budget ever allow).
I can’t agree with the first part of your final point, although I can understand the second part; it might make it slightly more complex. Many real written languages are extremely, and often inconsistent - English is often the canonical example - yet they allow the expression and communication of complex ideas and suitable nuances with great speed. I’ve laid out my arguments; I don’t really have much more to say to persuade you. I appreciate your comments.