File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ pub struct GqlEnum {
17
17
18
18
impl GqlEnum {
19
19
pub fn to_rust ( & self ) -> TokenStream {
20
- let variant_names: Vec < TokenStream > = self
21
- . variants
20
+ let variant_names: Vec < TokenStream > = self . variants
22
21
. iter ( )
23
22
. map ( |v| {
24
23
let name = Ident :: new ( & v. name , Span :: call_site ( ) ) ;
@@ -29,12 +28,15 @@ impl GqlEnum {
29
28
. collect ( ) ;
30
29
let variant_names = & variant_names;
31
30
let name_ident = Ident :: new ( & format ! ( "{}{}" , ENUMS_PREFIX , self . name) , Span :: call_site ( ) ) ;
32
- let constructors: Vec < _ > = variant_names
31
+ let constructors: Vec < _ > = self . variants
33
32
. iter ( )
34
- . map ( |v| quote ! ( #name_ident:: #v) )
33
+ . map ( |v| {
34
+ let v = Ident :: new ( & v. name , Span :: call_site ( ) ) ;
35
+ quote ! ( #name_ident:: #v)
36
+ } )
35
37
. collect ( ) ;
36
38
let constructors = & constructors;
37
- let variant_str: Vec < String > = self . variants . iter ( ) . map ( |v| v. name . clone ( ) ) . collect ( ) ;
39
+ let variant_str: Vec < & str > = self . variants . iter ( ) . map ( |v| v. name . as_str ( ) ) . collect ( ) ;
38
40
let variant_str = & variant_str;
39
41
40
42
let name = name_ident. clone ( ) ;
You can’t perform that action at this time.
0 commit comments