Skip to content

Commit

Permalink
Restore camelcase behaviour (ALL_CAPS -> AllCaps) (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie authored Feb 13, 2024
1 parent 89f2638 commit cb60567
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pb-jelly-gen/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,19 @@ fn camelcase(underscored: &str) -> String {
let mut chars = s.chars();
match chars.next() {
None => String::new(),
Some(first_char) => first_char.to_uppercase().collect::<String>() + chars.as_str(),
Some(first_char) => format!("{}{}", first_char.to_uppercase(), chars.as_str().to_lowercase()),
}
})
.collect()
}
#[test]
fn test_camelcase() {
assert_eq!(camelcase("foo"), "Foo");
assert_eq!(camelcase("foo_bar"), "FooBar");
assert_eq!(camelcase("FOO_BAR"), "FooBar");
assert_eq!(camelcase("OHNO128"), "Ohno128");
}

struct RustType<'a> {
ctx: &'a Context<'a>,
proto_file: &'a FileDescriptorProto,
Expand Down

0 comments on commit cb60567

Please sign in to comment.