@@ -486,6 +486,12 @@ impl<'a> ServiceGen<'a> {
486486 . any ( |method| !matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
487487 }
488488
489+ fn has_normal_method ( & self ) -> bool {
490+ self . methods
491+ . iter ( )
492+ . any ( |method| matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
493+ }
494+
489495 fn write_client ( & self , w : & mut CodeWriter ) {
490496 if async_on ( self . customize , "client" ) {
491497 self . write_async_client ( w)
@@ -568,8 +574,13 @@ impl<'a> ServiceGen<'a> {
568574 method_handler_name,
569575 ) ;
570576
577+ let has_normal_method = self . has_normal_method ( ) ;
571578 w. pub_fn ( & s, |w| {
572- w. write_line ( "let mut methods = HashMap::new();" ) ;
579+ if has_normal_method {
580+ w. write_line ( "let mut methods = HashMap::new();" ) ;
581+ } else {
582+ w. write_line ( "let methods = HashMap::new();" ) ;
583+ }
573584 for method in & self . methods [ 0 ..self . methods . len ( ) ] {
574585 w. write_line ( "" ) ;
575586 method. write_bind ( w) ;
@@ -588,9 +599,14 @@ impl<'a> ServiceGen<'a> {
588599 ) ;
589600
590601 let has_stream_method = self . has_stream_method ( ) ;
602+ let has_normal_method = self . has_normal_method ( ) ;
591603 w. pub_fn ( & s, |w| {
592604 w. write_line ( "let mut ret = HashMap::new();" ) ;
593- w. write_line ( "let mut methods = HashMap::new();" ) ;
605+ if has_normal_method {
606+ w. write_line ( "let mut methods = HashMap::new();" ) ;
607+ } else {
608+ w. write_line ( "let methods = HashMap::new();" ) ;
609+ }
594610 if has_stream_method {
595611 w. write_line ( "let mut streams = HashMap::new();" ) ;
596612 } else {
0 commit comments