Rust Inflector
Adds String based inflections for Rust. Snake, kebab, camel, sentence, class, title, upper, and lower 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 String types.
Documentation:
Documentation can be found here at the README or via rust docs below.
Installation:
As a crate
[]
= "0.4.0"
Compile yourself:
- Install Rust and cargo
- git clone https://github.com/whatisinternet/inflector
- Library: cd inflector && cargo build --release --lib
- You can find the library in target/release
Usage:
...
// to use methods like String.to_lower_case();
extern crate inflector;
use Inflector;
...
Or
...
// to use methods like to_lower_case(String);
extern crate inflector;
// use inflector::cases::classcase::to_class_case;
// use inflector::cases::classcase::is_class_case;
// use inflector::cases::camelcase::to_camel_case;
// use inflector::cases::camelcase::is_camel_case;
// use inflector::cases::pascalcase::to_pascal_case;
// use inflector::cases::pascalcase::is_pascal_case;
// use inflector::cases::screamingsnakecase::to_screamingsnake_case;
// use inflector::cases::screamingsnakecase::is_screamingsnake_case;
// use inflector::cases::snakecase::to_snake_case;
// use inflector::cases::snakecase::is_snake_case;
// use inflector::cases::kebabcase::to_kebab_case;
// use inflector::cases::kebabcase::is_kebab_case;
// use inflector::cases::sentencecase::to_sentence_case;
// use inflector::cases::sentencecase::is_sentence_case;
// use inflector::cases::titlecase::to_title_case;
// use inflector::cases::titlecase::is_title_case;
// use inflector::cases::tablecase::to_table_case;
// use inflector::cases::tablecase::is_table_case;
// use inflector::cases::uppercase::to_upper_case;
// use inflector::cases::uppercase::is_upper_case;
// use inflector::cases::lowercase::to_lower_case;
// use inflector::cases::lowercase::is_lower_case;
// use inflector::cases::::to_lower_case;
// use inflector::cases::lowercase::is_lower_case;
// use inflector::numbers::ordinalize::ordinalize;
// use inflector::numbers::deordinalize::deordinalize;
// use inflector::suffix::foreignkey::to_foreign_key;
// use inflector::suffix::foreignkey::is_foreign_key;
// use inflector::string::demodulize::demodulize;
// use inflector::string::deconstantize::deconstantize;
// use inflector::string::pluralize::to_plural;
// use inflector::string::singularize::to_singular;
...
Methods:
to_class_case
to_camel_case
to_pascal_case
to_screaming_snake_case
to_snake_case
to_kebab_case
to_sentence_case
to_title_case
to_table_case
to_upper_case
to_lower_case
ordinalize
deordinalize
demodulize
deconstantize
to_foreign_key
to_plural
to_singular
is_class_case
is_camel_case
is_pascal_case
is_screaming_snake_case
is_snake_case
is_kebab_case
is_sentence_case
is_title_case
is_table_case
is_upper_case
is_lower_case
is_foreign_key
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.
- Fork it ( https://github.com/whatisinternet/inflector/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request