Inflector 0.1.4

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

Rust Inflector

Build Status Crates.io

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


TODO:

  • Traits for String
  • Traits for str
  • Snake case
  • Kebab case
  • Camel case
  • Class case
  • Sentence case
  • Title case
  • Upper case
  • Lower case
  • Ordinalize and reverse
  • Foreign key
  • Demodulize
  • Deconstantize
  • Pluralize
  • Singularize
  • Table case

Installation:

As a crate

[dependencies]
Inflector = "0.1.4"

Compile yourself:

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

Usage:

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

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::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::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;
...
fn main() {
...
  let camel_case_string: String = to_camel_case("some_string".to_string());
...
}


Methods:

to_class_case(String) -> String
to_camel_case(String) -> String
to_snake_case(String) -> String
to_kebab_case(String) -> String
to_sentence_case(String) -> String
to_title_case(String) -> String
to_upper_case(String) -> String
to_lower_case(String) -> String
ordinalize(String) -> String
deordinalize(String) -> String
demodulize(String) -> String
deconstantize(String) -> String
to_foreign_key(String) -> String
is_class_case(String) -> bool
is_camel_case(String) -> bool
is_snake_case(String) -> bool
is_kebab_case(String) -> bool
is_sentence_case(String) -> bool
is_title_case(String) -> bool
is_upper_case(String) -> bool
is_lower_case(String) -> bool
is_foreign_key(String) -> bool

Contributing

  1. Fork it ( https://github.com/whatisinternet/inflector/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request