pub fn xml_to_snake_case(name: &str) -> StringExpand description
Convert an ISO 20022 XML element name (PascalCase / mixed-case / all-caps)
to a snake_case Rust identifier.
§Algorithm
The function inserts an underscore before each uppercase letter that
immediately follows a lowercase letter, or before an uppercase letter that
is immediately followed by a lowercase letter when the preceding character
is also uppercase (to handle runs of capitals such as "BICFI" or the
transition in "FIToFI").
§Examples
use mx20022_codegen::ir::lower::xml_to_snake_case;
assert_eq!(xml_to_snake_case("BizMsgIdr"), "biz_msg_idr");
assert_eq!(xml_to_snake_case("FIToFICstmrCdtTrf"), "fi_to_fi_cstmr_cdt_trf");
assert_eq!(xml_to_snake_case("BICFI"), "bicfi");
assert_eq!(xml_to_snake_case("LEI"), "lei");
assert_eq!(xml_to_snake_case("Id"), "id");
assert_eq!(xml_to_snake_case("URLAdr"), "url_adr");
assert_eq!(xml_to_snake_case("CreDt"), "cre_dt");