Expand description
§decamelize — convert camelCase to a separated lower-case string
Turn camelCase (or PascalCase) into a separated, lower-case string — fooBar →
foo_bar, unicornsAndRainbows → unicorns_and_rainbows. A faithful Rust port of the
widely-used decamelize npm package.
use decamelize::decamelize;
assert_eq!(decamelize("unicornsAndRainbows"), "unicorns_and_rainbows");
assert_eq!(decamelize("XMLHttpRequest"), "xml_http_request");
assert_eq!(decamelize("testGUILabel"), "test_gui_label");Use decamelize_with for a custom separator or to preserve consecutive uppercase
runs:
use decamelize::decamelize_with;
assert_eq!(decamelize_with("fooBar", "-", false), "foo-bar");
assert_eq!(decamelize_with("testGUILabel", "_", true), "test_GUI_label");Zero dependencies and #![no_std].
Functions§
- decamelize
- Convert
textfrom camelCase to a_-separated lower-case string. - decamelize_
with - Convert
textfrom camelCase using a customseparator.