From 82db76f4cde0813552a6d63235fb3947eb734171 Mon Sep 17 00:00:00 2001 From: Andrea Gunderson Date: Fri, 29 Sep 2023 09:29:18 -0500 Subject: [PATCH] Fix clippy::single_range_in_vec_init lint This is almost always incorrect, as it will result in a Vec that has only one element. Almost always, the programmer intended for it to include all elements in the range or for the end of the range to be the length instead. This means our correlations ids are not 16 characters long like we want. This fixes that issue. Signed-off-by: Andrea Gunderson --- src/consensus/zmq_driver.rs | 2 +- src/consensus/zmq_service.rs | 2 +- src/processor/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/consensus/zmq_driver.rs b/src/consensus/zmq_driver.rs index 23a9db8e1..b89fa0a72 100644 --- a/src/consensus/zmq_driver.rs +++ b/src/consensus/zmq_driver.rs @@ -44,7 +44,7 @@ const MAX_RETRY_DELAY: Duration = Duration::from_secs(3); fn generate_correlation_id() -> String { const LENGTH: usize = 16; let mut rng = rand::thread_rng(); - [0..LENGTH] + [0; LENGTH] .iter() .map(|_| rng.sample(Alphanumeric)) .map(char::from) diff --git a/src/consensus/zmq_service.rs b/src/consensus/zmq_service.rs index 7428d14df..ea0cee013 100644 --- a/src/consensus/zmq_service.rs +++ b/src/consensus/zmq_service.rs @@ -34,7 +34,7 @@ use std::time::Duration; fn generate_correlation_id() -> String { const LENGTH: usize = 16; let mut rng = rand::thread_rng(); - [0..LENGTH] + [0; LENGTH] .iter() .map(|_| rng.sample(Alphanumeric)) .map(char::from) diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 29fa8e848..1d2163f64 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -56,7 +56,7 @@ use self::zmq_context::ZmqTransactionContext; fn generate_correlation_id() -> String { const LENGTH: usize = 16; let mut rng = rand::thread_rng(); - [0..LENGTH] + [0; LENGTH] .iter() .map(|_| rng.sample(Alphanumeric)) .map(char::from)