MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / camel_case

Function camel_case

cranelift/codegen/meta/src/cdsl/mod.rs:32–50  ·  view source on GitHub ↗

Convert the string `s` to CamelCase.

(s: &str)

Source from the content-addressed store, hash-verified

30
31/// Convert the string `s` to CamelCase.
32pub fn camel_case(s: &str) -> String {
33 let mut output_chars = String::with_capacity(s.len());
34
35 let mut capitalize = true;
36 for curr_char in s.chars() {
37 if curr_char == '_' {
38 capitalize = true;
39 } else {
40 if capitalize {
41 output_chars.extend(curr_char.to_uppercase());
42 } else {
43 output_chars.push(curr_char);
44 }
45 capitalize = false;
46 }
47 }
48
49 output_chars
50}
51
52#[cfg(test)]
53mod tests {

Callers 4

gen_enum_typesFunction · 0.85
gen_getterFunction · 0.85
get_constraintFunction · 0.85
buildMethod · 0.85

Calls 3

lenMethod · 0.45
extendMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected