Change callback reform to not consume self
@@ -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)
}
