diff --git a/src/util.rs b/src/util.rs index 37f17e10..b4f09e30 100644 --- a/src/util.rs +++ b/src/util.rs @@ -28,10 +28,24 @@ impl Case { Cow::Borrowed(s) if s.is_constant_case() => cow, _ => cow.to_constant_case().into(), }, - Self::Pascal => match cow { - Cow::Borrowed(s) if s.is_pascal_case() => cow, - _ => cow.to_pascal_case().into(), - }, + Self::Pascal => { + if let Some((first, _)) = cow + .char_indices() + .find(|(_, c)| c != &'_' && !c.is_ascii_digit()) + { + if first != 0 { + let (prefix, s) = cow.split_at(first); + format!("{prefix}{}", s.to_pascal_case()).into() + } else { + match cow { + Cow::Borrowed(s) if s.is_pascal_case() => cow, + _ => cow.to_pascal_case().into(), + } + } + } else { + cow + } + } Self::Snake => match cow { Cow::Borrowed(s) if s.is_snake_case() => cow, _ => cow.to_snake_case().into(),