From 8e67bf23415b8a823dc250b64c9c8b930bc8b64e Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 13 Mar 2026 16:52:41 -1100 Subject: drop unnecessary dependency on pastey --- .../azalea-protocol-macros/src/utils.rs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 azalea-protocol/azalea-protocol-macros/src/utils.rs (limited to 'azalea-protocol/azalea-protocol-macros/src/utils.rs') 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 +} -- cgit v1.2.3