#snake #inflection #pluralize #inflector #camel

cruet

Adds String based inflections for Rust. Snake, kebab, camel, sentence, class, title and table cases as well as ordinalize, deordinalize, demodulize, foreign key, and pluralize/singularize are supported as both traits and pure functions acting on String types.

7 unstable releases

0.14.0 Nov 23, 2023
0.13.3 Feb 3, 2023
0.13.2 Nov 28, 2022
0.13.1 Sep 23, 2022
0.11.4 Sep 22, 2022

#80 in Text processing

Download history 23018/week @ 2024-07-21 23754/week @ 2024-07-28 25268/week @ 2024-08-04 27658/week @ 2024-08-11 21070/week @ 2024-08-18 29599/week @ 2024-08-25 27250/week @ 2024-09-01 24519/week @ 2024-09-08 19290/week @ 2024-09-15 25560/week @ 2024-09-22 20390/week @ 2024-09-29 15131/week @ 2024-10-06 15576/week @ 2024-10-13 15373/week @ 2024-10-20 14079/week @ 2024-10-27 16335/week @ 2024-11-03

62,847 downloads per month
Used in 27 crates (6 directly)

BSD-2-Clause

130KB
2.5K SLoC

Rust Inflector

This project is forked from https://github.com/whatisinternet/Inflector. The original author doesn't maintain this anymore.

Build Status Crates.ioCrate downloads

Adds String based inflections for Rust. Snake, kebab, train, camel, sentence, class, and title cases as well as ordinalize, deordinalize, demodulize, deconstantize, foreign key, table case, and pluralize/singularize are supported as both traits and pure functions acting on &str and String types.


Documentation:

Documentation can be found here at the README or via rust docs below.

Rust docs with examples


Installation:

As a crate

[dependencies]
cruet = "*"

Compile yourself:

  1. Install Rust and cargo
  2. git clone https://github.com/chrislearn/cruet
  3. Library: cd cruet && cargo build --release --lib
  4. You can find the library in target/release

Usage / Example:

// to use methods like String.to_lower_case();
use cruet::Inflector;
fn main() {
  let camel_case_string: String = "some_string".to_camel_case();
}

Or

// to use methods like to_snake_case(&str);
use cruet;

// use cruet::to_class_case;
// use cruet::is_class_case;

// use cruet::to_camel_case;
// use cruet::is_camel_case;

// use cruet::to_pascal_case;
// use cruet::is_pascal_case;

// use cruet::to_screamingsnake_case;
// use cruet::is_screamingsnake_case;

// use cruet::to_snake_case;
// use cruet::is_snake_case;

// use cruet::to_kebab_case;
// use cruet::is_kebab_case;

// use cruet::to_train_case;
// use cruet::is_train_case;

// use cruet::to_sentence_case;
// use cruet::is_sentence_case;

// use cruet::to_title_case;
// use cruet::is_title_case;

// use cruet::to_table_case;
// use cruet::is_table_case;

// use cruet::ordinalize;
// use cruet::deordinalize;

// use cruet::to_foreign_key;
// use cruet::is_foreign_key;

// use cruet::demodulize;
// use cruet::deconstantize;

// use cruet::to_plural;
// use cruet::to_singular;
fn main() {
  let camel_case_string: String = to_camel_case("some_string");
}

Contributing

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Dependencies

~2.1–3MB
~54K SLoC