diff --git a/instant-xml-macros/src/case.rs b/instant-xml-macros/src/case.rs index 540a141..aeef600 100644 --- a/instant-xml-macros/src/case.rs +++ b/instant-xml-macros/src/case.rs @@ -95,7 +95,11 @@ impl RenameRule { /// Apply a renaming rule to a struct field, returning the version expected in the source. 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 { None | LowerCase | SnakeCase => field, UpperCase => field.to_ascii_uppercase(), diff --git a/instant-xml/tests/de-nested.rs b/instant-xml/tests/de-nested.rs index 9a80a44..196d148 100644 --- a/instant-xml/tests/de-nested.rs +++ b/instant-xml/tests/de-nested.rs @@ -13,7 +13,7 @@ struct NestedDe { #[xml(ns("URI", bar = "BAZ", foo = "BAR"))] struct StructWithCustomFieldFromXml { #[xml(ns(BAR))] - flag: bool, + r#flag: bool, #[xml(attribute)] flag_attribute: bool, test: NestedDe,