diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index cbc77fe..9c4d1da 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -220,17 +220,16 @@ impl MemChecker{ } + /// Compare sections of a memChecker and a machine memory + /// + /// ### Parameters + /// + /// - **m_c** contains section of the memory checker + /// - **machine** contains the main memory pub fn compare_machine_memory(m_c: &MemChecker, machine: &Machine) -> bool { - - for section in m_c.sections.iter() { - for i in 0..section.len { - if machine.main_memory[section.addr + i] != section.content[i] { - return false; - } - } - } - - return true; + m_c.sections.iter().map(|section| { + !(0..section.len).into_iter().all(|i| machine.main_memory[section.addr + i] == section.content[i]) + }).all(|e| e == true) }