diff options
author | Till Hoeppner | 2014-11-03 16:39:57 +0100 |
---|---|---|
committer | Till Hoeppner | 2014-11-03 16:39:57 +0100 |
commit | 55b915a75f49957eaddefa74cbbf572ad186ee2f (patch) | |
tree | e18b0bb361802261db96f719eae7f0c9d3f3dbf3 /src/callback.rs | |
parent | fc27f8cee888acf70683badca9edadb45544822c (diff) | |
download | irsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.tar.gz irsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.tar.xz irsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.zip |
API improvements, but more copying
Diffstat (limited to 'src/callback.rs')
-rw-r--r-- | src/callback.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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<A: Sized + Send> { + items: Vec<fn(A)> +} + +impl<A: Sized + Clone + Send> Callback<A> { + pub fn new() -> Callback<A> { + 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())) {} + } +} |