Fixed some clippy complaining

This commit is contained in:
François Autin 2023-03-10 10:38:58 +01:00
parent 6db52669b4
commit 44e3f586e2
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -2,7 +2,6 @@ use std::fs;
use std::io::BufRead; use std::io::BufRead;
use std::io::BufReader; use std::io::BufReader;
use std::io::Lines; use std::io::Lines;
use std::io::Read;
use crate::Machine; use crate::Machine;
const MEM_SIZE : usize = 4096; const MEM_SIZE : usize = 4096;
@ -239,7 +238,7 @@ impl MemChecker{
fn string_hex_to_usize(s: &String) -> usize { fn string_hex_to_usize(s: &String) -> usize {
if s.len() == 0 { if s.is_empty() {
return 0; return 0;
} }
@ -253,7 +252,7 @@ fn string_hex_to_usize(s: &String) -> usize {
ret_value += base.pow(max_pow - (i as u32))*tmp; 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, 'E' | 'e' => 14,
'F' | 'f' => 15, 'F' | 'f' => 15,
_ => { _ => {
let ret : u8 = c.to_digit(10).unwrap() as u8; c.to_digit(10).unwrap() as u8
return ret;
}, },
} }
} }
@ -368,12 +366,7 @@ mod tests {
}; };
let section = Section::from(&section_format); let section = Section::from(&section_format);
let mut expected_vec: Vec<u8> = Vec::new(); let expected_vec: Vec<u8> = vec![0u8, 255u8, 10u8, 160u8, 165u8];
expected_vec.push(0u8);
expected_vec.push(255u8);
expected_vec.push(10u8);
expected_vec.push(160u8);
expected_vec.push(165u8);
//println!("Vec from created section {:?}", &section.content); //println!("Vec from created section {:?}", &section.content);
//println!("Expected vec {:?}", &expected_vec); //println!("Expected vec {:?}", &expected_vec);
@ -384,13 +377,13 @@ mod tests {
#[test] #[test]
fn test_mod(){ fn test_mod(){
let cond = (0%2) == 0; let cond = (0%2) == 0;
assert_eq!(true, cond); assert!(cond);
} }
#[test] #[test]
fn test_mod_2(){ fn test_mod_2(){
let cond = (1%2) == 1; let cond = (1%2) == 1;
assert_eq!(true, cond); assert!(cond);
} }
#[test] #[test]