aboutsummaryrefslogtreecommitdiff
path: root/azalea-block/block-macros/src/utils.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-07-07 05:58:44 +0000
committerGitHub <noreply@github.com>2022-07-07 05:58:44 +0000
commit31e5629ce1c8267802bbcb9d03b60a299d474e59 (patch)
tree5968b48af9b0c30149e908b043966c41dda0a61d /azalea-block/block-macros/src/utils.rs
parent27edd4f578e7b64fdaacefa26f691e2148707a8c (diff)
parent37d854c799236650da3deb025d8b32693531a27f (diff)
downloadazalea-drasl-31e5629ce1c8267802bbcb9d03b60a299d474e59.tar.xz
Merge branch 'main' into 1.19.1
Diffstat (limited to 'azalea-block/block-macros/src/utils.rs')
-rw-r--r--azalea-block/block-macros/src/utils.rs15
1 files changed, 6 insertions, 9 deletions
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<T: Clone>(items: &[Vec<T>]) -> Vec<Vec<T>> {
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<T: Clone>(items: &[Vec<T>]) -> Vec<Vec<T>> {
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