rust/tests/ui/vec_resize_to_zero.rs

21 lines
413 B
Rust
Raw Normal View History

2020-05-22 17:07:09 -05:00
#![warn(clippy::vec_resize_to_zero)]
fn main() {
let mut v = vec![1, 2, 3, 4, 5];
2020-05-22 17:07:09 -05:00
// applicable here
v.resize(0, 5);
//~^ ERROR: emptying a vector with `resize`
2020-05-22 17:07:09 -05:00
// not applicable
v.resize(2, 5);
let mut v = vec!["foo", "bar", "baz"];
2020-05-22 17:07:09 -05:00
2020-07-16 18:58:41 -05:00
// applicable here, but only implemented for integer literals for now
v.resize(0, "bar");
2020-05-22 17:07:09 -05:00
// not applicable
v.resize(2, "bar")
2020-05-22 17:07:09 -05:00
}