From e8deda5d2e45eb634700614009cbcc5b35949e26 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 25 Jun 2022 17:37:29 -0500 Subject: clippo --- azalea-block/block-macros/src/utils.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'azalea-block/block-macros/src/utils.rs') diff --git a/azalea-block/block-macros/src/utils.rs b/azalea-block/block-macros/src/utils.rs index 019fd60f..82095d86 100644 --- a/azalea-block/block-macros/src/utils.rs +++ b/azalea-block/block-macros/src/utils.rs @@ -1,6 +1,6 @@ pub fn combinations_of(items: &[Vec]) -> Vec> { let mut combinations = Vec::new(); - if items.len() == 0 { + if items.is_empty() { return combinations; }; if items.len() == 1 { @@ -13,8 +13,7 @@ pub fn combinations_of(items: &[Vec]) -> Vec> { for i in 0..items[0].len() { let item = &items[0][i]; for other_combinations in combinations_of(&items[1..]) { - let mut combination = Vec::new(); - combination.push(item.clone()); + let mut combination = vec![item.clone()]; combination.extend(other_combinations); combinations.push(combination); } @@ -29,13 +28,11 @@ pub fn to_pascal_case(s: &str) -> String { for c in s.chars() { if c == '_' { prev_was_underscore = true; + } else if prev_was_underscore { + result.push(c.to_ascii_uppercase()); + prev_was_underscore = false; } else { - if prev_was_underscore { - result.push(c.to_ascii_uppercase()); - prev_was_underscore = false; - } else { - result.push(c); - } + result.push(c); } } result -- cgit v1.2.3