File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -162,21 +162,22 @@ pub(super) fn handle_enum(item: ItemEnum) -> syn::Result<proc_macro2::TokenStrea
162162 variants,
163163 } = item. clone ( ) ;
164164
165- let mut variants_info = variants
165+ let ( mut catch_all_variants , variants_info) : ( Vec < _ > , Vec < _ > ) = variants
166166 . iter ( )
167167 . cloned ( )
168168 . map ( VariantInfo :: try_from)
169- . collect :: < syn:: Result < Vec < _ > > > ( ) ?;
170-
171- let catch_all = variants_info . pop_if ( |info| info . catch_all ) ;
169+ . collect :: < syn:: Result < Vec < _ > > > ( ) ?
170+ . into_iter ( )
171+ . partition ( |vinfo| vinfo . catch_all ) ;
172172
173173 // Ensure a no multiple `#[oparg(catch_all)]`
174- if catch_all. is_some ( ) && variants_info. iter ( ) . any ( |vinfo| vinfo. catch_all ) {
174+ let catch_all = catch_all_variants. pop ( ) ;
175+ if !catch_all_variants. is_empty ( ) {
175176 return Err ( Error :: new (
176177 item. span ( ) ,
177178 "Cannot define more than one `#[oparg(catch_all)]`" ,
178179 ) ) ;
179- } ;
180+ }
180181
181182 let variants_def = variants. iter ( ) . cloned ( ) . map ( |mut variant| {
182183 // Don't assign value. Enables more optimizations by the compiler.
You can’t perform that action at this time.
0 commit comments