globject_rs/
common.rs

1
2/// Convert a snake_case string to the camel case string
3pub fn to_camel_case(snake_case: &str, first_letter_uppercase: bool) -> String {
4	let mut ret = String::new();
5	let mut last_is_underscore = first_letter_uppercase;
6	for ch in snake_case.chars() {
7		if ch == '_' {
8			last_is_underscore = true;
9		} else {
10			if last_is_underscore {
11				for ch in ch.to_uppercase() {
12					ret.push(ch);
13				}
14			} else {
15				ret.push(ch);
16			}
17			last_is_underscore = false;
18		}
19	}
20	ret
21}