case_style
Converts from and to different case styles
Examples
There are two ways to use this libary. One is when you know the type upfront:
use CaseStyle;
let kebab = from_camelcase.to_kebabcase;
println!;
assert_eq!;
And one where you don't know exactly:
use CaseStyle;
let kebab = guess.unwrap.to_kebabcase;
println!;
assert_eq!;
The guess method is restrictive by design, so you should decide a backup type yourself like:
use CaseStyle;
let input = "user just typed this in :P";
let snake = guess
.unwrap_or
.to_snakecase;
println!;
assert_eq!;
In the previous example you can see that the convertion of styles does not remove odd characters. This you should also do youself.
use CaseStyle;
let input = "this is just some random input 🦖 ";
let filtered_input: String = input
.chars
.filter
.collect;
let filtered_input = filtered_input.trim;
let snake = guess
.unwrap_or
.to_camelcase;
println!;
assert_eq!;
Current supported formats:
- SnakeCase
- CamelCase
- ConstantCase
- KebabCase
- LowercaseSpace
- SentenceCase
for a up to date list look at the docs