@@ -407,12 +407,15 @@ enum HookAttributeKind {
407407}
408408
409409impl HookAttributeKind {
410- fn parse ( input : syn:: parse:: ParseStream , default_hook_path : ExprPath ) -> Result < Self > {
410+ fn parse (
411+ input : syn:: parse:: ParseStream ,
412+ default_hook_path : impl FnOnce ( ) -> ExprPath ,
413+ ) -> Result < Self > {
411414 if input. peek ( Token ! [ =] ) {
412415 input. parse :: < Token ! [ =] > ( ) ?;
413416 input. parse :: < Expr > ( ) . and_then ( Self :: from_expr)
414417 } else {
415- Ok ( Self :: Path ( default_hook_path) )
418+ Ok ( Self :: Path ( default_hook_path ( ) ) )
416419 }
417420 }
418421
@@ -569,34 +572,29 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> {
569572 } ;
570573 Ok ( ( ) )
571574 } else if nested. path . is_ident ( ON_ADD ) {
572- attrs. on_add = Some ( HookAttributeKind :: parse (
573- nested. input ,
574- parse_quote ! { Self :: on_add } ,
575- ) ?) ;
575+ attrs. on_add = Some ( HookAttributeKind :: parse ( nested. input , || {
576+ parse_quote ! { Self :: on_add }
577+ } ) ?) ;
576578 Ok ( ( ) )
577579 } else if nested. path . is_ident ( ON_INSERT ) {
578- attrs. on_insert = Some ( HookAttributeKind :: parse (
579- nested. input ,
580- parse_quote ! { Self :: on_insert } ,
581- ) ?) ;
580+ attrs. on_insert = Some ( HookAttributeKind :: parse ( nested. input , || {
581+ parse_quote ! { Self :: on_insert }
582+ } ) ?) ;
582583 Ok ( ( ) )
583584 } else if nested. path . is_ident ( ON_REPLACE ) {
584- attrs. on_replace = Some ( HookAttributeKind :: parse (
585- nested. input ,
586- parse_quote ! { Self :: on_replace } ,
587- ) ?) ;
585+ attrs. on_replace = Some ( HookAttributeKind :: parse ( nested. input , || {
586+ parse_quote ! { Self :: on_replace }
587+ } ) ?) ;
588588 Ok ( ( ) )
589589 } else if nested. path . is_ident ( ON_REMOVE ) {
590- attrs. on_remove = Some ( HookAttributeKind :: parse (
591- nested. input ,
592- parse_quote ! { Self :: on_remove } ,
593- ) ?) ;
590+ attrs. on_remove = Some ( HookAttributeKind :: parse ( nested. input , || {
591+ parse_quote ! { Self :: on_remove }
592+ } ) ?) ;
594593 Ok ( ( ) )
595594 } else if nested. path . is_ident ( ON_DESPAWN ) {
596- attrs. on_despawn = Some ( HookAttributeKind :: parse (
597- nested. input ,
598- parse_quote ! { Self :: on_despawn } ,
599- ) ?) ;
595+ attrs. on_despawn = Some ( HookAttributeKind :: parse ( nested. input , || {
596+ parse_quote ! { Self :: on_despawn }
597+ } ) ?) ;
600598 Ok ( ( ) )
601599 } else if nested. path . is_ident ( IMMUTABLE ) {
602600 attrs. immutable = true ;
0 commit comments