From c88a8b613022f3ccadb30dd0790eba342c0a31ef Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Thu, 8 Feb 2024 10:09:05 +0100 Subject: [PATCH] rust/pvapconfig: Fix Cargo clippy findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix findings from `cargo clippy --all-targets`. `warning: calls to `push` immediately after creation` The findings were in test code only. Also, replace a while loop with a function from Vec. Signed-off-by: Steffen Eiden Reviewed-by: Marc Hartmayer Reviewed-by: Harald Freudenberger Reviewed-by: Julian Ruess Signed-off-by: Jan Höppner --- rust/pvapconfig/src/main.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rust/pvapconfig/src/main.rs b/rust/pvapconfig/src/main.rs index a3a0bb30..9c67901f 100644 --- a/rust/pvapconfig/src/main.rs +++ b/rust/pvapconfig/src/main.rs @@ -607,13 +607,11 @@ mod tests { #[test] fn test_do_ap_config_invocation_1() { let test_apqns = make_test_apqns(); - let mut apqns: Vec = Vec::new(); - apqns.push(test_apqns[0].clone()); + let apqns: Vec = vec![test_apqns[0].clone()]; let secrets: Vec = Vec::new(); let secretlist = SecretList::new(secrets.len() as u16, secrets); let test_apconfigs = make_test_apconfigs(); - let mut apconfig: Vec = Vec::new(); - apconfig.push(test_apconfigs[0].clone()); + let apconfig: Vec = vec![test_apconfigs[0].clone()]; let apcfglist = ApConfigList::from_apconfigentry_vec(apconfig); let mut apqnlist = ApqnList::from_apqn_vec(apqns); let r = do_ap_config(&mut apqnlist, &secretlist, &apcfglist, true); @@ -625,16 +623,12 @@ mod tests { #[test] fn test_do_ap_config_invocation_2() { let test_apqns = make_test_apqns(); - let mut apqns: Vec = Vec::new(); - apqns.push(test_apqns[1].clone()); + let apqns: Vec = vec![test_apqns[1].clone()]; let mut secrets = make_test_secrets(); - while secrets.len() > 2 { - secrets.pop(); - } + secrets.truncate(2); let secretlist = SecretList::new(secrets.len() as u16, secrets); let test_apconfigs = make_test_apconfigs(); - let mut apconfig: Vec = Vec::new(); - apconfig.push(test_apconfigs[1].clone()); + let apconfig: Vec = vec![test_apconfigs[1].clone()]; let apcfglist = ApConfigList::from_apconfigentry_vec(apconfig); let mut apqnlist = ApqnList::from_apqn_vec(apqns); let r = do_ap_config(&mut apqnlist, &secretlist, &apcfglist, true);