Skip to content

Commit

Permalink
Change get_cpu to return mutable reference
Browse files Browse the repository at this point in the history
Co-authored-by: Ava Silver <[email protected]>
  • Loading branch information
breqdev and ava-silver committed Dec 30, 2023
1 parent bca14bf commit 688de5e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/systems/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 96 in src/systems/basic.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/basic.rs#L94-L96

Added lines #L94 - L96 were not covered by tests

fn tick(&mut self) -> Duration {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/c64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 318 in src/systems/c64/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/c64/mod.rs#L316-L318

Added lines #L316 - L318 were not covered by tests

fn tick(&mut self) -> Duration {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/easy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 98 in src/systems/easy.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/easy.rs#L96-L98

Added lines #L96 - L98 were not covered by tests

fn tick(&mut self) -> Duration {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/klaus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 50 in src/systems/klaus.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/klaus.rs#L48-L50

Added lines #L48 - L50 were not covered by tests

fn tick(&mut self) -> Duration {
Expand Down
2 changes: 1 addition & 1 deletion src/systems/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait BuildableSystem<RomRegistry, SystemConfig> {
/// 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;
Expand Down
4 changes: 2 additions & 2 deletions src/systems/pet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 215 in src/systems/pet/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/pet/mod.rs#L213-L215

Added lines #L213 - L215 were not covered by tests

fn tick(&mut self) -> Duration {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/vic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 316 in src/systems/vic/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/vic/mod.rs#L314-L316

Added lines #L314 - L316 were not covered by tests

fn tick(&mut self) -> instant::Duration {
Expand Down

0 comments on commit 688de5e

Please sign in to comment.