diff --git a/emulator/src/emulator/system/memory.rs b/emulator/src/emulator/system/memory.rs index e195b6b..5606474 100644 --- a/emulator/src/emulator/system/memory.rs +++ b/emulator/src/emulator/system/memory.rs @@ -83,7 +83,7 @@ impl MemoryUnit for MainStore { #[inline] fn read_word(&mut self, addr: u32) -> Result { - if addr % 4 != 0 { + if !addr.is_multiple_of(4) { return Err(ProcessorError::BadMemoryAccess(addr)); } @@ -116,7 +116,7 @@ impl MemoryUnit for MainStore { #[inline] fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> { - if addr % 4 != 0 { + if !addr.is_multiple_of(4) { return Err(ProcessorError::BadMemoryAccess(addr)); } diff --git a/emulator/src/emulator/system/model.rs b/emulator/src/emulator/system/model.rs index 3338848..cfd63f0 100644 --- a/emulator/src/emulator/system/model.rs +++ b/emulator/src/emulator/system/model.rs @@ -290,7 +290,6 @@ impl RegFile { }) } - #[must_use] pub const fn get(&self, reg: Register) -> Result { Ok(match reg { Register::Rg0 => self.rg0, diff --git a/emulator/src/emulator/system/processor/mod.rs b/emulator/src/emulator/system/processor/mod.rs index d9f48f3..710a4b4 100644 --- a/emulator/src/emulator/system/processor/mod.rs +++ b/emulator/src/emulator/system/processor/mod.rs @@ -21,10 +21,6 @@ pub struct Processor { pub cache: Cache, } -fn log(message: &str) { - println!("\x1b[32mINFO:\x1b[0m {message}"); -} - impl Processor { #[must_use] pub fn new(memory: Box, io_devices: Vec>) -> Self { diff --git a/emulator/src/emulator/ui/editor.rs b/emulator/src/emulator/ui/editor.rs index 47f4fce..c2edfff 100644 --- a/emulator/src/emulator/ui/editor.rs +++ b/emulator/src/emulator/ui/editor.rs @@ -117,10 +117,7 @@ impl Editor { .file_name() .unwrap_or_else(|| OsStr::new("Unnamed!")) .to_str() - .map_or_else( - || unreachable!("File name should be valid UTF-8."), - |ext| ext, - ); + .unwrap_or_else(|| unreachable!("File name should be valid UTF-8.")); } "Unnamed!" } @@ -129,12 +126,9 @@ impl Editor { if let Some(path) = &self.path { return path .extension() - .map_or_else(|| OsStr::new("Unknown!"), |ext| ext) + .unwrap_or_else(|| OsStr::new("Unknown!")) .to_str() - .map_or_else( - || unreachable!("File name should be valid UTF-8."), - |ext| ext, - ); + .unwrap_or_else(|| unreachable!("File name should be valid UTF-8.")); } "Unknown!" } @@ -398,7 +392,7 @@ impl Editor { _ => Syntax::default(), }; - let ed = CodeEditor::default() + let mut editor = CodeEditor::default() .id_source("editor") .with_fontsize(12.0) .with_rows(0) @@ -407,8 +401,6 @@ impl Editor { .with_numlines(true) .desired_width(available_width - 500.0); - let mut editor = ed.clone(); - editor.show(ui, &mut self.text); } @@ -451,7 +443,7 @@ impl Editor { Some("dsc") => { let output_path = Path::new(path).with_extension("dsa"); if let Err(e) = compiler::compile_file(path, &output_path) { - self.error = Some(format!("Compiler error: {}", e)); + self.error = Some(format!("Compiler error: {e}")); } let mut compiler = CompilerEngine::new(); @@ -461,7 +453,7 @@ impl Editor { let instructions = match compiler.wait_for_result() { Ok(instructions) => instructions, Err(e) => { - self.error = Some(format!("Assembler error: {}", e)); + self.error = Some(format!("Assembler error: {e}")); return; } }; diff --git a/emulator/src/emulator/ui/loader.rs b/emulator/src/emulator/ui/loader.rs index 75b2bdd..e75ecca 100644 --- a/emulator/src/emulator/ui/loader.rs +++ b/emulator/src/emulator/ui/loader.rs @@ -79,10 +79,7 @@ impl Loader { .file_name() .unwrap_or_else(|| OsStr::new("Unnamed!")) .to_str() - .map_or_else( - || unreachable!("File name should be valid UTF-8."), - |ext| ext, - ); + .unwrap_or_else(|| unreachable!("File name should be valid UTF-8.")); } "Unnamed!" }