Closed
Description
fn main() {
let x = vec![1,2,3];
match x[..] {
[1, 2, 3] => println!("123"),
_ => println!("not 123"),
}
}
Clippy output:
error: indexing into a vector may panic
--> src/main.rs:3:11
|
3 | match x[..] {
| ^^^^^ help: try this: `x.get(..)`
|
= note: `#[deny(clippy::match_on_vec_items)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
error: aborting due to previous error
However, this use of indexing is infallible.
(note that I'm silencing this lint globally anyway because I don't consider it useful)