1
- use std:: collections:: HashMap ;
1
+ use std:: collections:: { HashMap , HashSet } ;
2
2
3
3
use protobuf:: descriptor:: FileDescriptorProto ;
4
4
use protobuf:: reflect:: FileDescriptor ;
@@ -33,7 +33,7 @@ pub(crate) fn gen_all(
33
33
. map ( |f| Ok ( ( ProtoPath :: new ( f. proto ( ) . name ( ) ) ?, f) ) )
34
34
. collect :: < Result < _ , anyhow:: Error > > ( ) ?;
35
35
36
- let mut mods = Vec :: new ( ) ;
36
+ let mut mods = HashSet :: new ( ) ;
37
37
38
38
let customize = CustomizeElemCtx {
39
39
for_elem : customize. clone ( ) ,
@@ -49,15 +49,16 @@ pub(crate) fn gen_all(
49
49
) ) ;
50
50
let gen_file_result = gen_file ( file, & files_map, & root_scope, & customize, parser) ?;
51
51
results. push ( gen_file_result. compiler_plugin_result ) ;
52
- mods. push ( gen_file_result. mod_name ) ;
52
+ mods. insert ( gen_file_result. mod_name ) ;
53
53
}
54
54
55
55
if customize. for_elem . inside_protobuf . unwrap_or ( false ) {
56
56
results. push ( gen_well_known_types_mod ( ) ) ;
57
57
}
58
58
59
59
if customize. for_elem . gen_mod_rs . unwrap_or ( true ) {
60
- results. push ( gen_mod_rs ( & mods) ) ;
60
+ let r_vec: Vec < String > = mods. into_iter ( ) . collect ( ) ;
61
+ results. push ( gen_mod_rs ( & r_vec) ) ;
61
62
}
62
63
63
64
Ok ( results)
0 commit comments