diff options
| author | mat <github@matdoes.dev> | 2022-08-30 21:42:40 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-08-30 21:42:40 -0500 |
| commit | 0085f8a565563ecb6a9f4f87be8b336157aa1e55 (patch) | |
| tree | 4007e0dc98a4c3ad71656724c0263dfeccc76035 /azalea-block/block-macros/src/utils.rs | |
| parent | a6c5017e387954342a65358347cf89deead68944 (diff) | |
| download | azalea-drasl-0085f8a565563ecb6a9f4f87be8b336157aa1e55.tar.xz | |
make some stuff publishable on crates.io
Diffstat (limited to 'azalea-block/block-macros/src/utils.rs')
| -rw-r--r-- | azalea-block/block-macros/src/utils.rs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/azalea-block/block-macros/src/utils.rs b/azalea-block/block-macros/src/utils.rs deleted file mode 100644 index 82095d86..00000000 --- a/azalea-block/block-macros/src/utils.rs +++ /dev/null @@ -1,39 +0,0 @@ -pub fn combinations_of<T: Clone>(items: &[Vec<T>]) -> Vec<Vec<T>> { - let mut combinations = Vec::new(); - if items.is_empty() { - return combinations; - }; - if items.len() == 1 { - for item in &items[0] { - combinations.push(vec![item.clone()]); - } - return combinations; - }; - - for i in 0..items[0].len() { - let item = &items[0][i]; - for other_combinations in combinations_of(&items[1..]) { - let mut combination = vec![item.clone()]; - combination.extend(other_combinations); - combinations.push(combination); - } - } - - combinations -} - -pub fn to_pascal_case(s: &str) -> String { - let mut result = String::new(); - let mut prev_was_underscore = true; // set to true by default so the first character is capitalized - 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 { - result.push(c); - } - } - result -} |
