@@ -486,6 +486,12 @@ impl<'a> ServiceGen<'a> {
486
486
. any ( |method| !matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
487
487
}
488
488
489
+ fn has_normal_method ( & self ) -> bool {
490
+ self . methods
491
+ . iter ( )
492
+ . any ( |method| matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
493
+ }
494
+
489
495
fn write_client ( & self , w : & mut CodeWriter ) {
490
496
if async_on ( self . customize , "client" ) {
491
497
self . write_async_client ( w)
@@ -568,8 +574,13 @@ impl<'a> ServiceGen<'a> {
568
574
method_handler_name,
569
575
) ;
570
576
577
+ let has_normal_method = self . has_normal_method ( ) ;
571
578
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
+ }
573
584
for method in & self . methods [ 0 ..self . methods . len ( ) ] {
574
585
w. write_line ( "" ) ;
575
586
method. write_bind ( w) ;
@@ -588,9 +599,14 @@ impl<'a> ServiceGen<'a> {
588
599
) ;
589
600
590
601
let has_stream_method = self . has_stream_method ( ) ;
602
+ let has_normal_method = self . has_normal_method ( ) ;
591
603
w. pub_fn ( & s, |w| {
592
604
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
+ }
594
610
if has_stream_method {
595
611
w. write_line ( "let mut streams = HashMap::new();" ) ;
596
612
} else {
0 commit comments