Skip to content

Instantly share code, notes, and snippets.

View jprudent's full-sized avatar
🦋
Chasing butterflies

Jérôme Prudent jprudent

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