Skip to content

Commit

Permalink
dev: satisfying clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
milancermak committed Aug 23, 2024
1 parent 3e76b4f commit 006783d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions packages/macros/src/num_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -28,8 +29,7 @@ fn generate_op_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String {
.collect::<Vec<_>>()
.join(",\n");
format!("<{},\n{}>", params.join(", "), bounds)
},
);
});

let members_op = s
.members
Expand All @@ -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| {
Expand All @@ -70,8 +71,7 @@ fn generate_op_assign_trait_impl(op_info: &OpInfo, s: &StructInfo) -> String {
.collect::<Vec<_>>()
.join(",\n");
format!("<{},\n{}>", params.join(", "), bounds)
},
);
});

let members_op = s
.members
Expand Down
6 changes: 3 additions & 3 deletions packages/macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<Vec<String>> = None;
while let Some(node) = nodes.next() {
for node in nodes.by_ref() {
match node.kind(&db) {
WrappedGenericParamList => {
let params = node
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions packages/macros/src/zero_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -21,8 +22,7 @@ fn generate_zero_trait_impl(s: &StructInfo) -> String {
.collect::<Vec<_>>()
.join(",\n");
format!("<{},\n{}>", params.join(", "), bounds)
},
);
});

let zero_fn = s
.members
Expand Down

0 comments on commit 006783d

Please sign in to comment.