refactor: remove 1 layer of nesting

pull/12043/head
Nikita Revenco 2025-01-11 19:56:18 +00:00
parent 2a1bff5648
commit fdd1a1c78f
1 changed files with 16 additions and 12 deletions

View File

@ -35,21 +35,25 @@ pub fn smart_case_conversion(
}; };
for current in chars.skip_while(|ch| ch.is_whitespace()) { for current in chars.skip_while(|ch| ch.is_whitespace()) {
if current.is_alphanumeric() { if !current.is_alphanumeric() {
should_capitalize_current = true;
add_separator_if_needed(prev, buf);
prev = Some(current);
continue;
}
if has_camel_transition(prev, current) { if has_camel_transition(prev, current) {
add_separator_if_needed(prev, buf); add_separator_if_needed(prev, buf);
should_capitalize_current = true; should_capitalize_current = true;
} }
if should_capitalize_current { if should_capitalize_current {
buf.push(current.to_ascii_uppercase()); buf.push(current.to_ascii_uppercase());
should_capitalize_current = false; should_capitalize_current = false;
} else { } else {
buf.push(current.to_ascii_lowercase()); buf.push(current.to_ascii_lowercase());
} }
} else {
should_capitalize_current = true;
add_separator_if_needed(prev, buf);
}
prev = Some(current); prev = Some(current);
} }