From 47c449ae57b92bcf00faa1473427938e849d6ec5 Mon Sep 17 00:00:00 2001 From: KirillSemyonkin Date: Wed, 27 Sep 2023 14:30:02 +0300 Subject: [PATCH] Fix up commented reform/filter_reform --- packages/yew/src/callback.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/yew/src/callback.rs b/packages/yew/src/callback.rs index 20ff53ad9d9..2972562ecbf 100644 --- a/packages/yew/src/callback.rs +++ b/packages/yew/src/callback.rs @@ -153,17 +153,15 @@ impl Default for CallbackRef { } } -// TODO lifetimes ^_^' -/* impl CallbackRef { /// Creates a new callback from another callback and a function /// That when emitted will call that function and will emit the original callback pub fn reform(&self, func: F) -> CallbackRef where - F: Fn(T) -> IN + 'static, + F: Fn(&T) -> &IN + 'static, { let this = self.clone(); - let func = move |input| { + let func = move |input: &_| { let output = func(input); this.emit(output) }; @@ -175,14 +173,13 @@ impl CallbackRef { /// `value` to the original callback. pub fn filter_reform(&self, func: F) -> CallbackRef> where - F: Fn(T) -> Option + 'static, + F: Fn(&T) -> Option<&IN> + 'static, { let this = self.clone(); - let func = move |input| func(input).map(|output| this.emit(output)); + let func = move |input: &_| func(input).map(|output| this.emit(output)); CallbackRef::from(func) } } -*/ impl ImplicitClone for CallbackRef {} @@ -243,17 +240,15 @@ impl Default for CallbackRefMut { } } -// TODO lifetimes ^_^' -/* impl CallbackRefMut { /// Creates a new callback from another callback and a function /// That when emitted will call that function and will emit the original callback pub fn reform(&self, func: F) -> CallbackRefMut where - F: Fn(T) -> IN + 'static, + F: Fn(&mut T) -> &mut IN + 'static, { let this = self.clone(); - let func = move |input| { + let func = move |input: &mut _| { let output = func(input); this.emit(output) }; @@ -265,14 +260,13 @@ impl CallbackRefMut { /// `value` to the original callback. pub fn filter_reform(&self, func: F) -> CallbackRefMut> where - F: Fn(T) -> Option + 'static, + F: Fn(&mut T) -> Option<&mut IN> + 'static, { let this = self.clone(); - let func = move |input| func(input).map(|output| this.emit(output)); + let func = move |input: &mut _| func(input).map(|output| this.emit(output)); CallbackRefMut::from(func) } } -*/ impl ImplicitClone for CallbackRefMut {}