File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,12 @@ impl<'a> ServiceGen<'a> {
487487 . any ( |method| !matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
488488 }
489489
490+ fn has_unary_method ( & self ) -> bool {
491+ self . methods
492+ . iter ( )
493+ . any ( |method| matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
494+ }
495+
490496 fn write_client ( & self , w : & mut CodeWriter ) {
491497 if async_on ( self . customize , "client" ) {
492498 self . write_async_client ( w)
@@ -589,9 +595,14 @@ impl<'a> ServiceGen<'a> {
589595 ) ;
590596
591597 let has_stream_method = self . has_stream_method ( ) ;
598+ let has_unary_method = self . has_unary_method ( ) ;
592599 w. pub_fn ( & s, |w| {
593600 w. write_line ( "let mut ret = HashMap::new();" ) ;
594- w. write_line ( "let mut methods = HashMap::new();" ) ;
601+ if has_unary_method {
602+ w. write_line ( "let mut methods = HashMap::new();" ) ;
603+ } else {
604+ w. write_line ( "let methods = HashMap::new();" ) ;
605+ }
595606 if has_stream_method {
596607 w. write_line ( "let mut streams = HashMap::new();" ) ;
597608 } else {
Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ readme = "README.md"
1616protobuf-support = " 3.1.0"
1717protobuf = { version = " 2.27.1" }
1818protobuf-codegen = " 3.1.0"
19- ttrpc-compiler = " 0.6.1 "
19+ ttrpc-compiler = { path = " ../ttrpc-compiler " }
You can’t perform that action at this time.
0 commit comments