diff --git a/packages/macros/src/num_traits.rs b/packages/macros/src/num_traits.rs index d0fd4f0d..48be4578 100644 --- a/packages/macros/src/num_traits.rs +++ b/packages/macros/src/num_traits.rs @@ -14,9 +14,10 @@ fn generate_op_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String { .as_ref() .map_or(String::new(), |params| format!("<{}>", params.join(", "))); - let trait_bounds = s.generic_params.as_ref().map_or_else( - || String::new(), - |params| { + let trait_bounds = s + .generic_params + .as_ref() + .map_or_else(String::new, |params| { let bounds = params .iter() .flat_map(|param| { @@ -28,8 +29,7 @@ fn generate_op_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String { .collect::>() .join(",\n"); format!("<{},\n{}>", params.join(", "), bounds) - }, - ); + }); let members_op = s .members @@ -56,9 +56,10 @@ fn generate_op_assign_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String { .as_ref() .map_or(String::new(), |params| format!("<{}>", params.join(", "))); - let trait_bounds = s.generic_params.as_ref().map_or_else( - || String::new(), - |params| { + let trait_bounds = s + .generic_params + .as_ref() + .map_or_else(String::new, |params| { let bounds = params .iter() .flat_map(|param| { @@ -70,8 +71,7 @@ fn generate_op_assign_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String { .collect::>() .join(",\n"); format!("<{},\n{}>", params.join(", "), bounds) - }, - ); + }); let members_op = s .members diff --git a/packages/macros/src/parse.rs b/packages/macros/src/parse.rs index 5586fe32..57ac0d42 100644 --- a/packages/macros/src/parse.rs +++ b/packages/macros/src/parse.rs @@ -18,7 +18,7 @@ pub(crate) fn parse_struct_info(token_stream: TokenStream) -> StructInfo { // find struct name - the next TokenIdentifier after TeminalStruct let mut struct_name = String::new(); - while let Some(node) = nodes.next() { + for node in nodes.by_ref() { if node.kind(&db) == TerminalStruct { struct_name = nodes .find(|node| node.kind(&db) == TokenIdentifier) @@ -30,7 +30,7 @@ pub(crate) fn parse_struct_info(token_stream: TokenStream) -> StructInfo { // collect generic params or skip if there aren't any let mut generic_params: Option> = None; - while let Some(node) = nodes.next() { + for node in nodes.by_ref() { match node.kind(&db) { WrappedGenericParamList => { let params = node @@ -50,7 +50,7 @@ pub(crate) fn parse_struct_info(token_stream: TokenStream) -> StructInfo { // collect struct members - all TokenIdentifier nodes after each Member let mut members = Vec::new(); - while let Some(node) = nodes.next() { + for node in nodes { if node.kind(&db) == Member { let member = node .descendants(&db) diff --git a/packages/macros/src/zero_trait.rs b/packages/macros/src/zero_trait.rs index c86b8a8e..8a66312c 100644 --- a/packages/macros/src/zero_trait.rs +++ b/packages/macros/src/zero_trait.rs @@ -7,9 +7,10 @@ fn generate_zero_trait_impl(s: &StructInfo) -> String { .as_ref() .map_or(String::new(), |params| format!("<{}>", params.join(", "))); - let trait_bounds = s.generic_params.as_ref().map_or_else( - || String::new(), - |params| { + let trait_bounds = s + .generic_params + .as_ref() + .map_or_else(String::new, |params| { let bounds = params .iter() .flat_map(|param| { @@ -21,8 +22,7 @@ fn generate_zero_trait_impl(s: &StructInfo) -> String { .collect::>() .join(",\n"); format!("<{},\n{}>", params.join(", "), bounds) - }, - ); + }); let zero_fn = s .members