Skip to content

Instantly share code, notes, and snippets.

Avatar
🦋
Chasing butterflies

Jérôme Prudent jprudent

🦋
Chasing butterflies
View GitHub Profile
@jprudent
jprudent / playground.rs
Created Jan 18, 2017 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
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> {
@jprudent
jprudent / playground.rs
Created Jan 14, 2017 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
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);
}
}
@jprudent
jprudent / playground.rs
Created Jan 12, 2017 — forked from anonymous/playground.rs
Shared via Rust Playground
View playground.rs
struct Element {
x: u8
}
impl Element {
pub fn inc(&mut self, container: &Container) {
self.x = self.x + 1;
}
}