Skip to content

Commit 906040e

Browse files
committed
Address vec iteration review comment
1 parent 6121885 commit 906040e

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

bindgen/codegen/mod.rs

+17-21
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use proc_macro2::{Ident, Span};
5959
use quote::{ToTokens, TokenStreamExt};
6060

6161
use crate::{Entry, HashMap, HashSet};
62-
use itertools::izip;
6362
use std::borrow::Cow;
6463
use std::cell::Cell;
6564
use std::collections::VecDeque;
@@ -3286,7 +3285,7 @@ enum EnumBuilderKind {
32863285
NewType {
32873286
is_bitfield: bool,
32883287
is_global: bool,
3289-
// if the enum is named or not.
3288+
/// if the enum is named or not.
32903289
is_anonymous: bool,
32913290
},
32923291
Consts {
@@ -3479,25 +3478,18 @@ impl EnumBuilder {
34793478
rust_ty: &syn::Type,
34803479
enum_variants: &[EnumVariantInfo],
34813480
) -> proc_macro2::TokenStream {
3482-
let mut variant_idents = vec![];
3483-
let mut variant_values = vec![];
3484-
let mut variant_docs = vec![];
3485-
for v in enum_variants {
3486-
variant_idents.push(v.variant_name.clone());
3487-
variant_values.push(v.value.clone());
3488-
variant_docs.push(v.variant_doc.clone());
3489-
}
3490-
34913481
let enum_ident = self.enum_type;
34923482

34933483
// 1. Construct a list of the enum variants
34943484
let variants = match self.kind {
34953485
EnumBuilderKind::Rust { .. } => {
34963486
let mut variants = vec![];
34973487

3498-
for (variant_ident, variant_doc, variant_value) in
3499-
izip!(&variant_idents, &variant_docs, &variant_values)
3500-
{
3488+
for v in enum_variants {
3489+
let variant_doc = &v.variant_doc;
3490+
let variant_ident = &v.variant_name;
3491+
let variant_value = &v.value;
3492+
35013493
variants.push(quote! {
35023494
#variant_doc
35033495
#variant_ident = #variant_value,
@@ -3507,16 +3499,18 @@ impl EnumBuilder {
35073499
if variants.is_empty() {
35083500
variants.push(
35093501
quote! {__bindgen_cannot_repr_c_on_empty_enum = 0,},
3510-
)
3502+
);
35113503
}
35123504
variants
35133505
}
35143506
EnumBuilderKind::NewType { .. } => {
35153507
let mut variants = vec![];
35163508

3517-
for (variant_ident, variant_doc, variant_value) in
3518-
izip!(&variant_idents, &variant_docs, &variant_values)
3519-
{
3509+
for v in enum_variants {
3510+
let variant_doc = &v.variant_doc;
3511+
let variant_ident = &v.variant_name;
3512+
let variant_value = &v.value;
3513+
35203514
variants.push(quote! {
35213515
#variant_doc
35223516
pub const #variant_ident: #enum_ident = #variant_value;
@@ -3528,9 +3522,11 @@ impl EnumBuilder {
35283522
EnumBuilderKind::ModuleConsts { .. } => {
35293523
let mut variants = vec![];
35303524

3531-
for (variant_ident, variant_doc, variant_value) in
3532-
izip!(&variant_idents, &variant_docs, &variant_values)
3533-
{
3525+
for v in enum_variants {
3526+
let variant_doc = &v.variant_doc;
3527+
let variant_ident = &v.variant_name;
3528+
let variant_value = &v.value;
3529+
35343530
variants.push(quote! {
35353531
#variant_doc
35363532
pub const #variant_ident: #enum_ident = #variant_value;

0 commit comments

Comments
 (0)