Skip to content

Commit

Permalink
Change callback reform to not consume self (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored Dec 7, 2019
1 parent c583f73 commit 9e8ccac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ impl<IN> Callback<IN> {
impl<IN: 'static> Callback<IN> {
/// Changes input type of the callback to another.
/// Works like common `map` method but in an opposite direction.
pub fn reform<F, T>(self, func: F) -> Callback<T>
pub fn reform<F, T>(&self, func: F) -> Callback<T>
where
F: Fn(T) -> IN + 'static,
{
let this = self.clone();
let func = move |input| {
let output = func(input);
self.clone().emit(output);
this.emit(output);
};
Callback::from(func)
}
Expand Down

0 comments on commit 9e8ccac

Please sign in to comment.