2020-06-09 14:36:01 +00:00
|
|
|
#![warn(clippy::vec_resize_to_zero)]
|
|
|
|
|
|
|
|
fn main() {
|
2022-08-31 13:24:45 +00:00
|
|
|
let mut v = vec![1, 2, 3, 4, 5];
|
|
|
|
|
2020-06-09 14:36:01 +00:00
|
|
|
// applicable here
|
2022-08-31 13:24:45 +00:00
|
|
|
v.resize(0, 5);
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: emptying a vector with `resize`
|
2020-06-09 14:36:01 +00:00
|
|
|
|
|
|
|
// not applicable
|
2022-08-31 13:24:45 +00:00
|
|
|
v.resize(2, 5);
|
|
|
|
|
|
|
|
let mut v = vec!["foo", "bar", "baz"];
|
2020-06-09 14:36:01 +00:00
|
|
|
|
2020-07-26 19:07:07 +00:00
|
|
|
// applicable here, but only implemented for integer literals for now
|
2022-08-31 13:24:45 +00:00
|
|
|
v.resize(0, "bar");
|
2020-06-09 14:36:01 +00:00
|
|
|
|
|
|
|
// not applicable
|
2022-08-31 13:24:45 +00:00
|
|
|
v.resize(2, "bar")
|
2020-06-09 14:36:01 +00:00
|
|
|
}
|