From 688de5e2b4f498e0a86ba458b4e7746652b1b18f Mon Sep 17 00:00:00 2001 From: Brooke Chalmers Date: Fri, 29 Dec 2023 20:04:52 -0800 Subject: [PATCH] Change `get_cpu` to return mutable reference Co-authored-by: Ava Silver --- src/systems/basic.rs | 4 ++-- src/systems/c64/mod.rs | 4 ++-- src/systems/easy.rs | 4 ++-- src/systems/klaus.rs | 4 ++-- src/systems/mod.rs | 2 +- src/systems/pet/mod.rs | 4 ++-- src/systems/vic/mod.rs | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/systems/basic.rs b/src/systems/basic.rs index d1ac3f6..fab0117 100644 --- a/src/systems/basic.rs +++ b/src/systems/basic.rs @@ -91,8 +91,8 @@ pub struct BasicSystem { } impl System for BasicSystem { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> Duration { diff --git a/src/systems/c64/mod.rs b/src/systems/c64/mod.rs index e46a8c7..52d5752 100644 --- a/src/systems/c64/mod.rs +++ b/src/systems/c64/mod.rs @@ -313,8 +313,8 @@ pub struct C64System { } impl System for C64System { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> Duration { diff --git a/src/systems/easy.rs b/src/systems/easy.rs index e052925..4895b9a 100644 --- a/src/systems/easy.rs +++ b/src/systems/easy.rs @@ -93,8 +93,8 @@ pub struct Easy6502System { } impl System for Easy6502System { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> Duration { diff --git a/src/systems/klaus.rs b/src/systems/klaus.rs index bac9807..cb81f1c 100644 --- a/src/systems/klaus.rs +++ b/src/systems/klaus.rs @@ -45,8 +45,8 @@ pub struct KlausSystem { } impl System for KlausSystem { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> Duration { diff --git a/src/systems/mod.rs b/src/systems/mod.rs index 79b2f61..3f7e986 100644 --- a/src/systems/mod.rs +++ b/src/systems/mod.rs @@ -25,7 +25,7 @@ pub trait BuildableSystem { /// A representation of an emulated system. pub trait System { /// Return a mutable reference to the CPU used in this system. - fn get_cpu(&self) -> Box<&dyn Cpu>; + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu>; /// Advance the system by one tick. fn tick(&mut self) -> Duration; diff --git a/src/systems/pet/mod.rs b/src/systems/pet/mod.rs index 6a2c607..9ee8f5b 100644 --- a/src/systems/pet/mod.rs +++ b/src/systems/pet/mod.rs @@ -210,8 +210,8 @@ pub struct PetSystem { } impl System for PetSystem { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> Duration { diff --git a/src/systems/vic/mod.rs b/src/systems/vic/mod.rs index 71c1a61..bbd7840 100644 --- a/src/systems/vic/mod.rs +++ b/src/systems/vic/mod.rs @@ -311,8 +311,8 @@ pub struct Vic20System { } impl System for Vic20System { - fn get_cpu(&self) -> Box<&dyn Cpu> { - Box::new(&self.cpu) + fn get_cpu_mut(&mut self) -> Box<&mut dyn Cpu> { + Box::new(&mut self.cpu) } fn tick(&mut self) -> instant::Duration {