@@ -67,6 +67,7 @@ pub fn impl_union(
67
67
attrs : TokenStream ,
68
68
body : TokenStream ,
69
69
) -> Result < TokenStream , MacroError > {
70
+
70
71
// We are re-using the object attributes since they are almost the same.
71
72
let attrs = syn:: parse :: < util:: ObjectAttributes > ( attrs) ?;
72
73
@@ -75,8 +76,7 @@ pub fn impl_union(
75
76
if item. items . len ( ) != 1 {
76
77
return Err ( MacroError :: new (
77
78
item. span ( ) ,
78
- "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }"
79
- . to_string ( ) ,
79
+ "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }" . to_string ( ) ,
80
80
) ) ;
81
81
}
82
82
@@ -92,7 +92,7 @@ pub fn impl_union(
92
92
"Expected a path ending in a simple type identifier" . to_string ( ) ,
93
93
)
94
94
} ) ?;
95
- let name = attrs. name . unwrap_or_else ( || ty_ident. to_string ( ) ) ;
95
+ let name = attrs. name . unwrap_or_else ( || ty_ident. to_string ( ) ) ;
96
96
97
97
let juniper = util:: juniper_path ( is_internal) ;
98
98
@@ -130,9 +130,7 @@ pub fn impl_union(
130
130
. scalar
131
131
. as_ref ( )
132
132
. map ( |s| quote ! ( #s ) )
133
- . unwrap_or_else ( || {
134
- quote ! { #juniper:: DefaultScalarValue }
135
- } ) ;
133
+ . unwrap_or_else ( || { quote ! { #juniper:: DefaultScalarValue } } ) ;
136
134
137
135
let mut generics = item. generics . clone ( ) ;
138
136
if attrs. scalar . is_some ( ) {
@@ -141,12 +139,10 @@ pub fn impl_union(
141
139
// compatible with ScalarValueRef.
142
140
// This is done to prevent the user from having to specify this
143
141
// manually.
144
- let where_clause = generics
145
- . where_clause
146
- . get_or_insert ( syn:: parse_quote!( where ) ) ;
147
- where_clause
148
- . predicates
149
- . push ( syn:: parse_quote!( for <' __b> & ' __b #scalar: #juniper:: ScalarRefValue <' __b>) ) ;
142
+ let where_clause = generics. where_clause . get_or_insert ( syn:: parse_quote!( where ) ) ;
143
+ where_clause. predicates . push (
144
+ syn:: parse_quote!( for <' __b> & ' __b #scalar: #juniper:: ScalarRefValue <' __b>) ,
145
+ ) ;
150
146
}
151
147
152
148
let ( impl_generics, _, where_clause) = generics. split_for_impl ( ) ;
@@ -155,10 +151,7 @@ pub fn impl_union(
155
151
Some ( value) => quote ! ( . description( #value ) ) ,
156
152
None => quote ! ( ) ,
157
153
} ;
158
- let context = attrs
159
- . context
160
- . map ( |c| quote ! { #c } )
161
- . unwrap_or_else ( || quote ! { ( ) } ) ;
154
+ let context = attrs. context . map ( |c| quote ! { #c } ) . unwrap_or_else ( || quote ! { ( ) } ) ;
162
155
163
156
let output = quote ! {
164
157
impl #impl_generics #juniper:: GraphQLType <#scalar> for #ty #where_clause
0 commit comments