Expand description
§camelcase — convert a string to camelCase
Convert a dash/dot/underscore/space-separated string (or snake_case, kebab-case,
PascalCase, …) to camelCase: foo-bar → fooBar, foo_bar_baz → fooBarBaz. A
faithful Rust port of the widely-used
camelcase npm package.
use camelcase::camel_case;
assert_eq!(camel_case("foo-bar"), "fooBar");
assert_eq!(camel_case("foo_bar_baz"), "fooBarBaz");
assert_eq!(camel_case("XML-http"), "xmlHttp");Use camel_case_with for PascalCase or to preserve consecutive uppercase runs:
use camelcase::{camel_case_with, Options};
assert_eq!(camel_case_with("foo-bar", Options::new().pascal_case(true)), "FooBar");
assert_eq!(
camel_case_with("XML-http", Options::new().preserve_consecutive_uppercase(true)),
"XMLHttp"
);Structs§
- Options
- Options for
camel_case_with.
Functions§
- camel_
case - Convert
inputtocamelCasewith the default options. - camel_
case_ slice - Convert a list of fragments to
camelCase(each is trimmed, empties dropped, joined by-). - camel_
case_ with - Convert
inputtocamelCasewith the givenOptions.