pub fn to_pascal(s: &str) -> String {
s.split('_')
.map(|part| {
let mut chars = part.chars();
match chars.next() {
None => String::new(),
Some(c) => {
let mut s = c.to_uppercase().to_string();
s.push_str(chars.as_str());
s
}
}
})
.collect()
}
pub fn to_camel(s: &str) -> String {
let parts: Vec<&str> = s.split('_').collect();
let mut result = String::new();
for (i, part) in parts.iter().enumerate() {
let mut chars = part.chars();
match chars.next() {
None => {}
Some(c) => {
if i == 0 {
for lc in c.to_lowercase() {
result.push(lc);
}
} else {
for uc in c.to_uppercase() {
result.push(uc);
}
}
result.push_str(chars.as_str());
}
}
}
result
}
pub fn to_snake(s: &str) -> String {
let mut result = String::new();
for (i, c) in s.chars().enumerate() {
if c.is_uppercase() && i > 0 {
result.push('_');
}
for lc in c.to_lowercase() {
result.push(lc);
}
}
result
}
pub fn is_first_char_uppercase(s: &str) -> bool {
match s.chars().next() {
Some(first_char) => {
first_char.is_uppercase() }
None => false,
}
}
pub fn is_first_char_lowercase(s: &str) -> bool {
match s.chars().next() {
Some(first_char) => {
first_char.is_lowercase() }
None => false,
}
}