From f847040e69a7ea16be9535784446584ac4f29094 Mon Sep 17 00:00:00 2001 From: Antonios Barotsis Date: Sat, 27 Jan 2024 10:51:50 +0100 Subject: [PATCH] Fix clippy performance lint See https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization --- tests/utils.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/utils.rs b/tests/utils.rs index ed7237a..5a649c4 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -51,8 +51,7 @@ pub fn create_files_in(dir: &Path, files: &[&str]) { // write random content to a file pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) { - let mut data = Vec::new(); - data.resize(rng.gen_range(0..4096), 0); + let mut data = vec![0; rng.gen_range(0..4096)]; rng.fill_bytes(&mut data); file.write_all(&data).unwrap(); }