Skip to content

Commit

Permalink
trailing _
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Feb 3, 2024
1 parent 55a14ea commit 5cf7959
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased]

- Add `base-address-shift` config flag
- Use `PascalCase` for type idents, fix case changing bugs

## [v0.31.5] - 2024-01-04

Expand Down
17 changes: 13 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ impl Case {
{
if first != 0 {
let (prefix, s) = cow.split_at(first);
format!("{prefix}{}", s.to_pascal_case()).into()
// Keep trailing "_"
if let Some(s) = s.strip_suffix('_') {
format!("{prefix}{}_", s.to_pascal_case()).into()
} else {
format!("{prefix}{}", s.to_pascal_case()).into()
}
} else {
match cow {
Cow::Borrowed(s) if s.is_pascal_case() => cow,
_ => cow.to_pascal_case().into(),
if let Some(s) = cow.strip_suffix('_') {
format!("{}_", s.to_pascal_case()).into()
} else {
match cow {
Cow::Borrowed(s) if s.is_pascal_case() => cow,
_ => cow.to_pascal_case().into(),
}
}
}
} else {
Expand Down

0 comments on commit 5cf7959

Please sign in to comment.