diff options
| author | mat <git@matdoes.dev> | 2026-03-13 16:52:41 -1100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-13 16:52:41 -1100 |
| commit | 8e67bf23415b8a823dc250b64c9c8b930bc8b64e (patch) | |
| tree | e2a1f6b10648c8bd21f96baf9b1a90637b6437c5 /azalea-protocol/azalea-protocol-macros/src/utils.rs | |
| parent | 75a7ec5f2989073a3534f377bfeb0d23de844593 (diff) | |
| download | azalea-drasl-8e67bf23415b8a823dc250b64c9c8b930bc8b64e.tar.xz | |
drop unnecessary dependency on pastey
Diffstat (limited to 'azalea-protocol/azalea-protocol-macros/src/utils.rs')
| -rw-r--r-- | azalea-protocol/azalea-protocol-macros/src/utils.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/azalea-protocol/azalea-protocol-macros/src/utils.rs b/azalea-protocol/azalea-protocol-macros/src/utils.rs new file mode 100644 index 00000000..cdfe0412 --- /dev/null +++ b/azalea-protocol/azalea-protocol-macros/src/utils.rs @@ -0,0 +1,29 @@ +pub fn to_camel_case(snake_case: &str) -> String { + let mut camel_case = String::new(); + let mut capitalize_next = true; + for c in snake_case.chars() { + if c == '_' { + capitalize_next = true; + } else { + if capitalize_next { + camel_case.push(c.to_ascii_uppercase()); + } else { + camel_case.push(c); + } + capitalize_next = false; + } + } + camel_case +} +pub fn to_snake_case(camel_case: &str) -> String { + let mut snake_case = String::new(); + for c in camel_case.chars() { + if c.is_ascii_uppercase() { + snake_case.push('_'); + snake_case.push(c.to_ascii_lowercase()); + } else { + snake_case.push(c); + } + } + snake_case +} |
