7 releases (4 breaking)

0.5.1 Jan 17, 2026
0.5.0 Jan 17, 2026
0.4.0 Jan 7, 2026
0.3.0 Jul 14, 2023
0.1.0 Dec 29, 2021

#494 in Text processing

Download history 277/week @ 2025-12-10 506/week @ 2025-12-17 225/week @ 2025-12-31 613/week @ 2026-01-07 397/week @ 2026-01-14 245/week @ 2026-01-21 378/week @ 2026-01-28 463/week @ 2026-02-04 283/week @ 2026-02-11 44/week @ 2026-02-18 134/week @ 2026-02-25 419/week @ 2026-03-04 76/week @ 2026-03-11 9/week @ 2026-03-18 223/week @ 2026-03-25

749 downloads per month
Used in grace-cli

BSD-2-Clause

32KB
491 lines

ReCase

crates-io Changelog api-docs License

Changes the input text to the desired convention case.

 

Install

Add this to your Cargo.toml:

[dependencies]
recase = "0.5.1"

 

Features

  • Zero Allocation Logic: Heavily optimized runtime and memory usage. It allocates exactly once (for the result string).
  • Unicode Aware: Handles complex graphemes, and acronyms correctly aside from emojis, they are treated the same as lowercase characters for now.
  • Acronyms: now support acronyms and will not split them into seperated characters anymore.

 

Example:

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"
}

 

All supported convention cases:

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

 

Limitations

  • Emojis are treated the same as lEmoji will be counted as lowercase characterowercase characters.
  • Some UTF-8 characters can't be lowercased, like "SS" which is the uppercased form of "ß" or the dotless I (I) will turn into a normal i. There might be more cases that I failed to notice.

 

Acknowledgements

Heavily influenced by ReCase from techniboogie-dart.

Dependencies

~1MB
~13K SLoC