diff options
author | Till Höppner | 2015-04-18 15:29:14 +0200 |
---|---|---|
committer | Till Höppner | 2015-04-18 15:29:14 +0200 |
commit | 057d3e0bdb4bb46749267b45223281fd9afc956d (patch) | |
tree | f6994ad12dd7d765d58958599705fb3d9d2c4d16 /src/callback.rs | |
parent | 326b5d9d96a5f45fa8b371f2a78394bcd87030e0 (diff) | |
parent | 4eea7cdff640f31f6595ec880d5405665fbd5c55 (diff) | |
download | irsc-057d3e0bdb4bb46749267b45223281fd9afc956d.tar.gz irsc-057d3e0bdb4bb46749267b45223281fd9afc956d.tar.xz irsc-057d3e0bdb4bb46749267b45223281fd9afc956d.zip |
Merge pull request #3 from tilpner/refactor
Refactor
Diffstat (limited to 'src/callback.rs')
-rw-r--r-- | src/callback.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/callback.rs b/src/callback.rs index c62ebf8..b2027f6 100644 --- a/src/callback.rs +++ b/src/callback.rs @@ -1,15 +1,15 @@ -pub struct Callback<A: Sized + Send> { - items: Vec<fn(A)> +pub struct Callback<A: Sized> { + items: Vec<fn(&mut A)> } -impl<A: Sized + Clone + Send> Callback<A> { +impl<A: Sized> 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 register(&mut self, f: fn(&mut A)) { + self.items.push(f) } - pub fn fire(&self, v: &A) { - for _ in self.items.iter().map(|&c| c(v.clone())) {} + pub fn fire(&self, v: &mut A) { + for _ in self.items.iter().map(|&c| c(v)) {} } } |