Skip to content

Commit a8517b5

Browse files
committed
revert to inflections
1 parent e3a661c commit a8517b5

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
88
## [Unreleased]
99

1010
- Bump MSRV to 1.65
11-
- Replace `inflections` with `convert_case`, optimize case change/sanitize
11+
- Optimize case change/sanitize
1212
- Fix dangling implicit derives
1313
- Fix escaping <> and & characters in doc attributes
1414

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ yaml = ["dep:serde_yaml"]
4646
clap = { version = "4.0", optional = true }
4747
irx-config = { version = "3.1", features = ["cmd", "toml-parser"], optional = true }
4848
env_logger = { version = "0.10", optional = true }
49-
convert_case = "0.6"
49+
inflections = "1.1"
5050
log = { version = "~0.4", features = ["std"] }
5151
quote = "1.0"
5252
proc-macro2 = "1.0"

src/util.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::borrow::Cow;
22

33
use crate::svd::{Access, Device, DimElement, Field, RegisterInfo, RegisterProperties};
44
use html_escape::encode_text_minimal;
5+
use inflections::Inflect;
56
use proc_macro2::{Ident, Span, TokenStream};
67
use quote::quote;
78
use std::collections::HashSet;
@@ -69,45 +70,43 @@ pub enum Case {
6970

7071
impl Case {
7172
pub fn to_case<'a>(&self, s: &'a str) -> Cow<'a, str> {
72-
use convert_case::{Case as CCase, Casing};
7373
match self {
7474
Self::Constant => {
75-
if s.is_case(CCase::UpperSnake) {
75+
if s.is_constant_case() {
7676
s.into()
7777
} else {
78-
s.to_case(CCase::UpperSnake).into()
78+
s.to_constant_case().into()
7979
}
8080
}
8181
Self::Pascal => {
82-
if s.is_case(CCase::Pascal) {
82+
if s.is_pascal_case() {
8383
s.into()
8484
} else {
85-
s.to_case(CCase::Pascal).into()
85+
s.to_pascal_case().into()
8686
}
8787
}
8888
Self::Snake => {
89-
if s.is_case(CCase::Snake) {
89+
if s.is_snake_case() {
9090
s.into()
9191
} else {
92-
s.to_case(CCase::Snake).into()
92+
s.to_snake_case().into()
9393
}
9494
}
9595
}
9696
}
9797
pub fn cow_to_case<'a>(&self, cow: Cow<'a, str>) -> Cow<'a, str> {
98-
use convert_case::{Case as CCase, Casing};
9998
match self {
10099
Self::Constant => match cow {
101-
Cow::Borrowed(s) if s.is_case(CCase::UpperSnake) => cow,
102-
_ => cow.to_case(CCase::UpperSnake).into(),
100+
Cow::Borrowed(s) if s.is_constant_case() => cow,
101+
_ => cow.to_constant_case().into(),
103102
},
104103
Self::Pascal => match cow {
105-
Cow::Borrowed(s) if s.is_case(CCase::Pascal) => cow,
106-
_ => cow.to_case(CCase::Pascal).into(),
104+
Cow::Borrowed(s) if s.is_pascal_case() => cow,
105+
_ => cow.to_pascal_case().into(),
107106
},
108107
Self::Snake => match cow {
109-
Cow::Borrowed(s) if s.is_case(CCase::Snake) => cow,
110-
_ => cow.to_case(CCase::Snake).into(),
108+
Cow::Borrowed(s) if s.is_snake_case() => cow,
109+
_ => cow.to_snake_case().into(),
111110
},
112111
}
113112
}

0 commit comments

Comments
 (0)