2023-08-21 11:50:53 -05:00
|
|
|
#![warn(clippy::reserve_after_initialization)]
|
|
|
|
|
|
|
|
fn main() {
|
2023-08-21 16:36:15 -05:00
|
|
|
// Should lint
|
|
|
|
let mut v1: Vec<usize> = vec![];
|
|
|
|
v1.reserve(10);
|
|
|
|
|
|
|
|
// Should lint
|
|
|
|
let capacity = 10;
|
|
|
|
let mut v2: Vec<usize> = vec![];
|
|
|
|
v2.reserve(capacity);
|
|
|
|
|
|
|
|
// Shouldn't lint
|
|
|
|
let mut v3 = vec![1];
|
|
|
|
v3.reserve(10);
|
|
|
|
|
|
|
|
// Shouldn't lint
|
|
|
|
let mut v4: Vec<usize> = Vec::with_capacity(10);
|
2023-08-21 11:50:53 -05:00
|
|
|
}
|