8 releases (5 breaking)

0.6.0 Sep 8, 2022
0.5.0 Dec 27, 2021
0.4.0 May 18, 2020
0.3.2 May 15, 2020
0.1.0 Apr 17, 2020

#15 in Text processing

Download history 1338803/week @ 2024-07-30 1365826/week @ 2024-08-06 1372915/week @ 2024-08-13 1428995/week @ 2024-08-20 1334462/week @ 2024-08-27 1444347/week @ 2024-09-03 1431351/week @ 2024-09-10 1371711/week @ 2024-09-17 1522667/week @ 2024-09-24 1548676/week @ 2024-10-01 1538820/week @ 2024-10-08 1628687/week @ 2024-10-15 1627691/week @ 2024-10-22 1556511/week @ 2024-10-29 1559622/week @ 2024-11-05 1317792/week @ 2024-11-12

6,359,658 downloads per month
Used in 2,675 crates (723 directly)

MIT license

79KB
1K SLoC

Convert Case

Converts to and from various cases.

Rust Library convert_case

Convert case was written in Rust and is ready to be used inline with your rust code as a library.

use convert_case::{Case, Casing};

assert_eq!("ronnieJamesDio", "Ronnie_James_dio".to_case(Case::Camel));
assert_eq!("io_stream", "IOStream".to_case(Case::Snake));
assert_eq!(
    "2020-04-16 My Cat Cali",
    "2020-04-16_my_cat_cali".from_case(Case::Snake).to_case(Case::Title)
);

You can read the API documentation on docs.rs for a list of all features and read lots of examples.

Command Line Utility ccase

The command line utility ccase was made to leverage the tools in the convert_case library.

$ ccase -t title super_mario_64
Super Mario 64

$ ccase -f snake -t title 2020-04-15_my_cat_cali
2020-04-16 My Cat Cali

$ ccase -t camel "convert to camel"
convertToCamel

You can read more about the ccase executable in the ccase directory within this repository.

convert_case ccase
Repository github github
Crate crates.io crates.io
Documentation docs.rs

Cases

This is list of cases that convert_case supports. Some cases are simply aliases of others. The "Random" and "PseudoRandom" cases are provided in the convert_case library with the "random" feature, and are automatically provided in the ccase binary.

Case Example
Upper MY VARIABLE NAME
Lower my variable name
Title My Variable Name
Toggle mY vARIABLE nAME
Alternating mY vArIaBlE nAmE
Camel myVariableName
Pascal MyVariableName
UpperCamel MyVariableName
Snake my_variable_name
UpperSnake MY_VARIABLE_NAME
ScreamingSnake MY_VARIABLE_NAME
Kebab my-variable-name
Cobol MY-VARIABLE-NAME
Train My-Variable-Name
Flat myvariablename
UpperFlat MYVARIABLENAME
Random MY vaRiabLe nAME
PseudoRandom mY VaRiAblE nAMe

License

Licensed under MIT License.

Dependencies

~315–700KB
~11K SLoC