From 44e3f586e2657dac6c272446c3497267345f3798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Fri, 10 Mar 2023 10:38:58 +0100 Subject: [PATCH] Fixed some clippy complaining --- src/simulator/mem_cmp.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index 70f86f5..00c45b8 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -2,7 +2,6 @@ use std::fs; use std::io::BufRead; use std::io::BufReader; use std::io::Lines; -use std::io::Read; use crate::Machine; const MEM_SIZE : usize = 4096; @@ -239,7 +238,7 @@ impl MemChecker{ fn string_hex_to_usize(s: &String) -> usize { - if s.len() == 0 { + if s.is_empty() { return 0; } @@ -253,7 +252,7 @@ fn string_hex_to_usize(s: &String) -> usize { ret_value += base.pow(max_pow - (i as u32))*tmp; } - return ret_value; + ret_value } @@ -271,8 +270,7 @@ fn one_hex_to_dec(c: char) -> u8 { 'E' | 'e' => 14, 'F' | 'f' => 15, _ => { - let ret : u8 = c.to_digit(10).unwrap() as u8; - return ret; + c.to_digit(10).unwrap() as u8 }, } } @@ -368,12 +366,7 @@ mod tests { }; let section = Section::from(§ion_format); - let mut expected_vec: Vec = Vec::new(); - expected_vec.push(0u8); - expected_vec.push(255u8); - expected_vec.push(10u8); - expected_vec.push(160u8); - expected_vec.push(165u8); + let expected_vec: Vec = vec![0u8, 255u8, 10u8, 160u8, 165u8]; //println!("Vec from created section {:?}", §ion.content); //println!("Expected vec {:?}", &expected_vec); @@ -384,13 +377,13 @@ mod tests { #[test] fn test_mod(){ let cond = (0%2) == 0; - assert_eq!(true, cond); + assert!(cond); } #[test] fn test_mod_2(){ let cond = (1%2) == 1; - assert_eq!(true, cond); + assert!(cond); } #[test]