Improve support for raw identifier field names
This commit is contained in:
parent
6c4cd8bd55
commit
8c2964b318
|
@ -95,7 +95,11 @@ impl RenameRule {
|
||||||
|
|
||||||
/// Apply a renaming rule to a struct field, returning the version expected in the source.
|
/// Apply a renaming rule to a struct field, returning the version expected in the source.
|
||||||
pub fn apply_to_field(&self, ident: &Ident) -> String {
|
pub fn apply_to_field(&self, ident: &Ident) -> String {
|
||||||
let field = ident.to_string();
|
let mut field = ident.to_string();
|
||||||
|
if field.starts_with("r#") {
|
||||||
|
field = field[2..].to_string();
|
||||||
|
}
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
None | LowerCase | SnakeCase => field,
|
None | LowerCase | SnakeCase => field,
|
||||||
UpperCase => field.to_ascii_uppercase(),
|
UpperCase => field.to_ascii_uppercase(),
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct NestedDe {
|
||||||
#[xml(ns("URI", bar = "BAZ", foo = "BAR"))]
|
#[xml(ns("URI", bar = "BAZ", foo = "BAR"))]
|
||||||
struct StructWithCustomFieldFromXml {
|
struct StructWithCustomFieldFromXml {
|
||||||
#[xml(ns(BAR))]
|
#[xml(ns(BAR))]
|
||||||
flag: bool,
|
r#flag: bool,
|
||||||
#[xml(attribute)]
|
#[xml(attribute)]
|
||||||
flag_attribute: bool,
|
flag_attribute: bool,
|
||||||
test: NestedDe,
|
test: NestedDe,
|
||||||
|
|
Loading…
Reference in New Issue