| Crates.io | recase |
| lib.rs | recase |
| version | 0.5.1 |
| created_at | 2021-12-29 05:04:35.643293+00 |
| updated_at | 2026-01-17 13:11:08.122123+00 |
| description | Changes the convention case of input text. |
| homepage | https://github.com/ThiDinh21/recase |
| repository | https://github.com/ThiDinh21/recase |
| max_upload_size | |
| id | 504653 |
| size | 35,263 |
Changes the input text to the desired convention case.
 
Add this to your Cargo.toml:
[dependencies]
recase = "0.5.1"
 
 
use recase::{ReCase, Casing};
fn main() {
const INPUT: &str = "Löng and meaningless-HTML_Text";
// Using the Casing Trait
println!("{}", INPUT.to_kebab_case()); // Prints "löng-and-meaningless-html-text"
let recase = ReCase::new(INPUT);
println!("{}", recase.snake_case()); // Prints "löng_and_meaningless_html_text"
println!("{}", recase.camel_case()); // Prints "löngAndMeaninglessHTMLText"
}
 
| Convention Case | Trait Method (on &str / String) |
Struct Method (ReCase) |
Example Result |
|---|---|---|---|
| camelCase | .to_camel_case() |
.camel_case() |
exampleString |
| snake_case | .to_snake_case() |
.snake_case() |
example_string |
| PascalCase | .to_pascal_case() |
.pascal_case() |
ExampleString |
| kebab-case | .to_kebab_case() |
.kebab_case() |
example-string |
| dot.case | .to_dot_case() |
.dot_case() |
example.string |
| path/case | .to_path_case() |
.path_case() |
example/string |
| windows\path\case | .to_windows_path_case() |
.windows_path_case() |
example\string |
| normal case | .to_normal_case() |
.normal_case() |
example string |
| Title Case | .to_title_case() |
.title_case() |
Example String |
| Sentence case | .to_sentence_case() |
.sentence_case() |
Example string |
| Header-Case | .to_header_case() |
.header_case() |
Example-String |
| UPPER_SNAKE_CASE | .to_upper_snake_case() |
.upper_snake_case() |
EXAMPLE_STRING |
| AlTeRnAtInG cAsE | .to_alternating_case() |
.alternating_case() |
eXaMpLe StRiNg |
 
 
Heavily influenced by ReCase from techniboogie-dart.