From de0013ad3ee22e2cfd12c38cb673d8e998c36ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Wed, 8 Mar 2023 13:34:12 +0100 Subject: [PATCH] remade compare_machine_memory --- src/simulator/mem_cmp.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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) }