зеркало из https://github.com/mozilla/gecko-dev.git
faf6cad78c
Differential Revision: https://phabricator.services.mozilla.com/D45719 --HG-- rename : third_party/rust/regex-0.2.2/src/freqs.rs => third_party/rust/aho-corasick/src/byte_frequencies.rs rename : third_party/rust/crc/Cargo.toml => third_party/rust/blake2b_simd/Cargo.toml rename : third_party/rust/miniz_oxide_c_api/LICENSE => third_party/rust/miniz_oxide/LICENSE rename : third_party/rust/redox_users/tests/group => third_party/rust/redox_users/tests/etc/group rename : third_party/rust/redox_users/tests/passwd => third_party/rust/redox_users/tests/etc/passwd rename : third_party/rust/redox_users/tests/shadow => third_party/rust/redox_users/tests/etc/shadow rename : third_party/rust/utf8-ranges/src/lib.rs => third_party/rust/regex-syntax/src/utf8.rs rename : third_party/rust/crossbeam-channel/LICENSE-APACHE => third_party/rust/rust-argon2/LICENSE-APACHE rename : third_party/rust/memchr-1.0.2/COPYING => third_party/rust/winapi-util/COPYING rename : third_party/rust/ucd-util/Cargo.toml => third_party/rust/winapi-util/Cargo.toml rename : third_party/rust/memchr-1.0.2/LICENSE-MIT => third_party/rust/winapi-util/LICENSE-MIT rename : third_party/rust/memchr-1.0.2/UNLICENSE => third_party/rust/winapi-util/UNLICENSE extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
src | ||
tests | ||
.cargo-checksum.json | ||
Cargo.toml | ||
README.md |
README.md
Rust Inflector
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.
Installation:
As a crate
[dependencies]
Inflector = "*"
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 / Example:
...
// to use methods like String.to_lower_case();
extern crate inflector;
use inflector::Inflector;
...
fn main() {
...
let camel_case_string: String = "some_string".to_camel_case();
...
}
Or
...
// to use methods like to_snake_case(&str);
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::traincase::to_train_case;
// use inflector::cases::traincase::is_train_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::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;
...
fn main() {
...
let camel_case_string: String = to_camel_case("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:
[dependencies.Inflector]
version = "*"
default-features = false
Or
Inflector = {version="*", default-features=false}
To test this crate locally with features off try:
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.