|
|
|
|
|
by the_mitsuhiko
1175 days ago
|
|
> The downside is that you may get a weird bug and only after a while see that you accidentally overwrote a function parameter and the Rust compiler didn't even warn you about it. It will absolutely warn about this: fn foo(i: u32) -> u32 {
let i = 42;
i
}
fn main() {
dbg!(foo(42));
}
results in warning: unused variable: `i`
--> src/main.rs:1:8
|
1 | fn foo(i: u32) -> u32 {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
|
= note: `#[warn(unused_variables)]` on by default
|
|