Rust (i)nflector

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. forked from: https://github.com/whatisinternet/Inflector


Documentation:

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

Rust docs with examples


Installation:

As a crate

toml [dependencies] inflector = "*"

Compile yourself:

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

Usage / Example:

```rust ... // to use methods like String.tolowercase(); extern crate inflector; use inflector::inflector; ... fn main() { ... let camelcasestring: String = "somestring".tocamel_case(); ... }

```

Or

```rust ... // to use methods like tosnakecase(&str); extern crate inflector;

// use inflector::cases::classcase::toclasscase; // use inflector::cases::classcase::isclasscase;

// use inflector::cases::camelcase::tocamelcase; // use inflector::cases::camelcase::iscamelcase;

// use inflector::cases::pascalcase::topascalcase; // use inflector::cases::pascalcase::ispascalcase;

// use inflector::cases::screamingsnakecase::toscreamingsnakecase; // use inflector::cases::screamingsnakecase::isscreamingsnakecase;

// use inflector::cases::snakecase::tosnakecase; // use inflector::cases::snakecase::issnakecase;

// use inflector::cases::kebabcase::tokebabcase; // use inflector::cases::kebabcase::iskebabcase;

// use inflector::cases::traincase::totraincase; // use inflector::cases::traincase::istraincase;

// use inflector::cases::sentencecase::tosentencecase; // use inflector::cases::sentencecase::issentencecase;

// use inflector::cases::titlecase::totitlecase; // use inflector::cases::titlecase::istitlecase;

// use inflector::cases::tablecase::totablecase; // use inflector::cases::tablecase::istablecase;

// use inflector::numbers::ordinalize::ordinalize; // use inflector::numbers::deordinalize::deordinalize;

// use inflector::suffix::foreignkey::toforeignkey; // use inflector::suffix::foreignkey::isforeignkey;

// use inflector::string::demodulize::demodulize; // use inflector::string::deconstantize::deconstantize;

// use inflector::string::pluralize::toplural; // use inflector::string::singularize::tosingular; ... fn main() { ... let camelcasestring: String = tocamelcase("some_string"); ... }

```

Advanced installation and usage:

If the project doesn't require singularize, pluralize, class, table, demodulize, deconstantize. Then in your cargo.toml you may wish to specify:

toml [dependencies.inflector] version = "*" default-features = false

Or

```toml inflector = {version="*", default-features=false}

```

To test this crate locally with features off try:

shell cargo test --no-default-features

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.