@@ -37,7 +37,7 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
3737
3838 let mut num_children = None ;
3939 let mut get_child = None ;
40- let mut for_child_node = None ;
40+ let mut child_node = None ;
4141 let mut find_child_index = None ;
4242 let mut make_child_id = None ;
4343 for ( index, impl_) in scope. impls . iter ( ) . enumerate ( ) {
@@ -50,8 +50,8 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
5050
5151 for item in & impl_. items {
5252 if let ImplItem :: Fn ( ref item) = item {
53- if item. sig . ident == "for_child_node " {
54- for_child_node = Some ( item. sig . ident . clone ( ) ) ;
53+ if item. sig . ident == "child_node " {
54+ child_node = Some ( item. sig . ident . clone ( ) ) ;
5555 }
5656 } else if let ImplItem :: Type ( ref item) = item {
5757 if item. ident == "Data" {
@@ -293,11 +293,11 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
293293 if get_child. is_none ( ) {
294294 emit_warning ! ( span, "fn num_children without fn get_child" ) ;
295295 }
296- if for_child_node . is_none ( ) {
297- emit_warning ! ( span, "fn num_children without fn for_child_node " ) ;
296+ if child_node . is_none ( ) {
297+ emit_warning ! ( span, "fn num_children without fn child_node " ) ;
298298 }
299299 }
300- if let Some ( span) = get_child. as_ref ( ) . or ( for_child_node . as_ref ( ) ) {
300+ if let Some ( span) = get_child. as_ref ( ) . or ( child_node . as_ref ( ) ) {
301301 if num_children. is_none ( ) {
302302 emit_warning ! ( span, "associated impl of `fn Tile::num_children` required" ) ;
303303 }
@@ -321,7 +321,7 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
321321 #core_path. status. require_rect( & #core_path. _id) ;
322322 } ;
323323
324- let do_impl_widget_children = get_child. is_none ( ) && for_child_node . is_none ( ) ;
324+ let do_impl_widget_children = get_child. is_none ( ) && child_node . is_none ( ) ;
325325 let fns_get_child = if do_impl_widget_children {
326326 let mut get_rules = quote ! { } ;
327327 for ( index, child) in children. iter ( ) . enumerate ( ) {
@@ -349,7 +349,7 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
349349 let item_idents = collect_idents ( widget_impl) ;
350350 let has_item = |name| item_idents. iter ( ) . any ( |( _, ident) | ident == name) ;
351351
352- // If the user impls Widget, they must supply type Data and fn for_child_node
352+ // If the user impls Widget, they must supply type Data and fn child_node
353353
354354 // Always impl fn as_node
355355 widget_impl. items . push ( Verbatim ( widget_as_node ( ) ) ) ;
@@ -841,26 +841,25 @@ pub fn impl_widget(
841841 } ;
842842
843843 get_mut_rules. append_all ( if let Some ( ref data) = child. data_binding {
844- quote ! { #i => closure ( #path. as_node( #data) ) , }
844+ quote ! { #i => Some ( #path. as_node( #data) ) , }
845845 } else {
846846 if let Some ( ref span) = child. attr_span {
847- quote_spanned ! { * span=> #i => closure ( #path. as_node( data) ) , }
847+ quote_spanned ! { * span=> #i => Some ( #path. as_node( data) ) , }
848848 } else {
849- quote ! { #i => closure ( #path. as_node( data) ) , }
849+ quote ! { #i => Some ( #path. as_node( data) ) , }
850850 }
851851 } ) ;
852852 }
853853
854854 quote ! {
855- fn for_child_node (
856- & mut self ,
857- data: & Self :: Data ,
855+ fn child_node< ' __n> (
856+ & ' __n mut self ,
857+ data: & ' __n Self :: Data ,
858858 index: usize ,
859- closure: Box <dyn FnOnce ( :: kas:: Node <' _>) + ' _>,
860- ) {
859+ ) -> Option <:: kas:: Node <' __n>> {
861860 match index {
862861 #get_mut_rules
863- _ => ( ) ,
862+ _ => None ,
864863 }
865864 }
866865 }
@@ -885,7 +884,7 @@ pub fn impl_widget(
885884pub fn widget_as_node ( ) -> Toks {
886885 quote ! {
887886 #[ inline]
888- fn as_node<' a >( & ' a mut self , data: & ' a Self :: Data ) -> :: kas:: Node <' a > {
887+ fn as_node<' __a >( & ' __a mut self , data: & ' __a Self :: Data ) -> :: kas:: Node <' __a > {
889888 :: kas:: Node :: new( self , data)
890889 }
891890 }
0 commit comments