#case #conventions #text

recase

Changes the convention case of input text

4 releases (2 breaking)

0.3.0 Jul 14, 2023
0.2.0 Mar 14, 2022
0.1.1 Feb 17, 2022
0.1.0 Dec 29, 2021

#637 in Text processing

37 downloads per month
Used in grace-cli

BSD-2-Clause

24KB
450 lines

ReCase

crates-io api-docs Maintenance License

Changes the input text to the desired convention case.

 

Install

Add this to your Cargo.toml:

[dependencies]
recase = "0.3.0"

 

Example:

use recase::ReCase;

fn main() {
    const INPUT: &str = "Löng and meaningless-Ẽxample_Text";

    let recase1 = ReCase::new(INPUT);
    let recase2 = ReCase::new(String::from(INPUT));

    println!("{}", recase1.snake_case());     // Prints "löng_and_meaningless_ẽxample_text"
    println!("{}", recase2.camel_case());     // Prints "löngAndMeaninglessẼxampleText"
}

 

All supported convention cases:

  • camelCase
  • snake_case
  • PascalCase
  • kebab-case
  • dot.case
  • path/case
  • windows\path\case
  • normal case
  • Title Case
  • Sentence case
  • Header-Case
  • UPPER_CASE_SNAKE_CASE
  • aLtErNaTiNg CaSe

 

Limitations

  • The crate has not undergone any runtime optimization.
  • Some UTF-8 characters can't be lowercased, like "SS" which is the uppercased form of "ß". There might be more cases that I failed to notice.

 

Acknowledgements

Heavily influenced by ReCase from techniboogie-dart.

Dependencies

~355KB