From 42f2e00f88a9b1a9c206318a5c089a1e5c07cb04 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Sat, 7 Dec 2019 17:17:26 -0500 Subject: [PATCH] Change callback reform to not consume self (#779) --- src/callback.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/callback.rs b/src/callback.rs index 1f56dec59ea..15b1e8a17a8 100644 --- a/src/callback.rs +++ b/src/callback.rs @@ -46,13 +46,14 @@ impl Callback { impl Callback { /// Changes input type of the callback to another. /// Works like common `map` method but in an opposite direction. - pub fn reform(self, func: F) -> Callback + pub fn reform(&self, func: F) -> Callback 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) }