2023-07-27 06:40:22 -05:00
|
|
|
#![warn(clippy::vec_resize_to_zero)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut v = vec![1, 2, 3, 4, 5];
|
|
|
|
|
|
|
|
// applicable here
|
|
|
|
v.clear();
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: emptying a vector with `resize`
|
2023-07-27 06:40:22 -05:00
|
|
|
|
|
|
|
// 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")
|
|
|
|
}
|