This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Hook; | |
struct Timer; | |
struct ComputerUnit<'a> { | |
hooks: Vec<&'a mut Hook>, | |
memory: Mmu<'a> | |
} | |
impl<'a> ComputerUnit<'a> { | |
fn new(hooks: Vec<&'a mut Hook>, timer: &'a Timer) -> ComputerUnit<'a> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CpuHook { | |
counter: u64 | |
} | |
impl CpuHook { | |
pub fn inspect(&mut self, cpu: &Cpu) { | |
// here I don't use the cpu but I could log the cpu register in a mutable file for instance | |
self.counter = self.counter.wrapping_add(1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Element { | |
x: u8 | |
} | |
impl Element { | |
pub fn inc(&mut self, container: &Container) { | |
self.x = self.x + 1; | |
} | |
} |