#[allow(dead_code)]
fn print_grid(empty: (usize,usize), goal: (usize,usize), (w,h): (usize,usize)) {
for y in 0..h {
for x in 0..w {
let s: String = match (x,y) {
empty => "_".to_string(),
goal => "G".to_string(),
(0,0) => "*".to_string(),
_ => ".".to_string()
};
print!("{s} ");
}
println!();
}
}
This match statement generates an unreachable pattern warning:
warning: unreachable pattern
--> src/lib.rs:75:17
|
74 | empty => "_".to_string(),
| ----- matches any value
75 | goal => "G".to_string(),
| ^^^^ unreachable pattern
|
= note: `#[warn(unreachable_patterns)]` on by default
And indeed, when I use this function, any pattern will lead to "_" being printed.
It may be obvious but I can't figure it out. Is this an error from Rust (I doubt it)? Is there something important I'm missing?