Rust Inflector

This project is forked from https://github.com/chrislearn/cruet.

The intent of this library is to emulate https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html as closely as possible to allow for rust implementations of ruby tools.

CI Audit

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

toml [dependencies] ruby_inflector = "*"

Compile yourself:

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

Usage / Example:

```rust // to use methods like String.tolowercase(); use rubyinflector::Inflector; fn main() { let camelcasestring: String = "somestring".tocamelcase(); }

```

Or

```rust // to use methods like tosnakecase(&str); use ruby_inflector;

// use rubyinflector::toclasscase; // use rubyinflector::isclasscase;

// use rubyinflector::tocamelcase; // use rubyinflector::iscamelcase;

// use rubyinflector::topascalcase; // use rubyinflector::ispascalcase;

// use rubyinflector::toscreamingsnakecase; // use rubyinflector::isscreamingsnakecase;

// use rubyinflector::tosnakecase; // use rubyinflector::issnakecase;

// use rubyinflector::tokebabcase; // use rubyinflector::iskebabcase;

// use rubyinflector::totraincase; // use rubyinflector::istraincase;

// use rubyinflector::tosentencecase; // use rubyinflector::issentencecase;

// use rubyinflector::totitlecase; // use rubyinflector::istitlecase;

// use rubyinflector::totablecase; // use rubyinflector::istablecase;

// use rubyinflector::ordinalize; // use rubyinflector::deordinalize;

// use rubyinflector::toforeignkey; // use rubyinflector::isforeignkey;

// use rubyinflector::demodulize; // use rubyinflector::deconstantize;

// use rubyinflector::toplural; // use rubyinflector::tosingular; fn main() { let camelcasestring: String = tocamelcase("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.