pub fn pascal_to_snake(name: &str) -> StringExpand description
Convert a PascalCase or mixed-case name to snake_case with correct acronym handling.
Use this instead of heck::ToSnakeCase when the input is a PascalCase Rust type or
enum variant name — heck inserts an underscore before every uppercase letter, which
incorrectly splits acronym-style names like Rdfa into rd_fa.
Rules:
- A run of consecutive uppercase letters is treated as a single acronym word.
- If the run is followed by a lowercase letter, the last uppercase char begins the
next word (e.g.
XMLHttp→xml_http). - A single uppercase letter followed by lowercase is a normal word start.
Examples:
MyType→my_typeRdfa→rdfaHTMLParser→html_parserXMLHttpRequest→xml_http_requestIOError→io_errorURLPath→url_pathJSONLD→jsonld