From b031ab75bdd132c8d470605185575e6347b7e904 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 6 Sep 2021 23:40:36 +0200 Subject: [PATCH] Use getrandom instead of rand for benches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code didn’t build, and this one includes fewer dependencies than the full rand set of crates. --- Cargo.toml | 2 +- benches/read_entry.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2ce7e602..b3ab6b9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ thiserror = "1.0" [dev-dependencies] bencher = "0.1" -rand = "0.7" +getrandom = "0.2" walkdir = "2" [features] diff --git a/benches/read_entry.rs b/benches/read_entry.rs index 25c0b94a..af9affe3 100644 --- a/benches/read_entry.rs +++ b/benches/read_entry.rs @@ -3,7 +3,7 @@ use bencher::{benchmark_group, benchmark_main}; use std::io::{Cursor, Read, Write}; use bencher::Bencher; -use rand::Rng; +use getrandom::getrandom; use zip::{ZipArchive, ZipWriter}; fn generate_random_archive(size: usize) -> Vec { @@ -14,7 +14,7 @@ fn generate_random_archive(size: usize) -> Vec { writer.start_file("random.dat", options).unwrap(); let mut bytes = vec![0u8; size]; - rand::thread_rng().fill_bytes(&mut bytes); + getrandom(&mut bytes).unwrap(); writer.write_all(&bytes).unwrap(); writer.finish().unwrap().into_inner()