blob: b2027f6426a4c24aa7a152925c34e158cb6607c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
pub struct Callback<A: Sized> {
items: Vec<fn(&mut A)>
}
impl<A: Sized> Callback<A> {
pub fn new() -> Callback<A> {
Callback { items: Vec::new() }
}
pub fn register(&mut self, f: fn(&mut A)) {
self.items.push(f)
}
pub fn fire(&self, v: &mut A) {
for _ in self.items.iter().map(|&c| c(v)) {}
}
}
|