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> {
487
487
. any ( |method| !matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
488
488
}
489
489
490
+ fn has_unary_method ( & self ) -> bool {
491
+ self . methods
492
+ . iter ( )
493
+ . any ( |method| matches ! ( method. method_type( ) . 0 , MethodType :: Unary ) )
494
+ }
495
+
490
496
fn write_client ( & self , w : & mut CodeWriter ) {
491
497
if async_on ( self . customize , "client" ) {
492
498
self . write_async_client ( w)
@@ -589,9 +595,14 @@ impl<'a> ServiceGen<'a> {
589
595
) ;
590
596
591
597
let has_stream_method = self . has_stream_method ( ) ;
598
+ let has_unary_method = self . has_unary_method ( ) ;
592
599
w. pub_fn ( & s, |w| {
593
600
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
+ }
595
606
if has_stream_method {
596
607
w. write_line ( "let mut streams = HashMap::new();" ) ;
597
608
} else {
Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ readme = "README.md"
16
16
protobuf-support = " 3.1.0"
17
17
protobuf = { version = " 2.27.1" }
18
18
protobuf-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