From 55b915a75f49957eaddefa74cbbf572ad186ee2f Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Mon, 3 Nov 2014 16:39:57 +0100 Subject: API improvements, but more copying --- src/callback.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/callback.rs (limited to 'src/callback.rs') diff --git a/src/callback.rs b/src/callback.rs new file mode 100644 index 0000000..c62ebf8 --- /dev/null +++ b/src/callback.rs @@ -0,0 +1,15 @@ +pub struct Callback { + items: Vec +} + +impl Callback { + pub fn new() -> Callback { + Callback { items: Vec::new() } + } + pub fn register(&mut self, f: &fn(A)) { + self.items.push(*f) + } + pub fn fire(&self, v: &A) { + for _ in self.items.iter().map(|&c| c(v.clone())) {} + } +} -- cgit v1.2.3