Skip to content

Instantly share code, notes, and snippets.

@s18alg
s18alg / proto_event_engine.rs
Created April 12, 2020 13:53
This is my first try at writing an event manager in rust
#![allow(dead_code)] // TODO: remove this at some point
use std::collections::HashMap;
// TODO: Does it make sense to aggregate and return the result?
// Lambda prototype: (id: String, message: String) -> ()
type EventCallback<'a> = Box<dyn FnMut(String, String) + 'a>;
pub struct EventEngine {
event: HashMap<String, Vec<EventCallback<'static>>>,
}
@s18alg
s18alg / Polymorphic C
Last active September 18, 2019 19:30
#include <stdlib.h>
#include <stdio.h>
typedef struct s_main {
void (*f)(void);
} t_main;
typedef struct s_c1 {
void (*f)(void);
int padding;