mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 15:41:10 +00:00
21 lines
408 B
Rust
21 lines
408 B
Rust
|
#![warn(clippy::vec_resize_to_zero)]
|
||
|
|
||
|
fn main() {
|
||
|
let mut v = vec![1, 2, 3, 4, 5];
|
||
|
|
||
|
// applicable here
|
||
|
v.clear();
|
||
|
//~^ ERROR: emptying a vector with `resize`
|
||
|
|
||
|
// not applicable
|
||
|
v.resize(2, 5);
|
||
|
|
||
|
let mut v = vec!["foo", "bar", "baz"];
|
||
|
|
||
|
// applicable here, but only implemented for integer literals for now
|
||
|
v.resize(0, "bar");
|
||
|
|
||
|
// not applicable
|
||
|
v.resize(2, "bar")
|
||
|
}
|