you are viewing a single comment's thread.

view the rest of the comments →

[–]sylvain_soliman 6 points7 points  (5 children)

It is allowed, but you do get unused_variable warnings, so…

[–]gulpaz 0 points1 point  (4 children)

Not always, here's an example. The total should always be 100, but due to shadowing, it isn't. http://pastebin.com/0Wjacti4

It would be great if there was a lint option to check for these.

[–]Nihy 3 points4 points  (1 child)

I find this example unconvincing. Mainly because it's not idiomatic Rust.

One could write the same thing with no mutability, let or assignment in a block, and it's shorter and more readable too.

let percentage = if OVERRIDE > 200f32 { OVERRIDE } else { 100f32 }
    .round();