Crates.io | voca_rs |
lib.rs | voca_rs |
version | 1.15.2 |
source | src |
created_at | 2018-09-16 17:07:23.697152 |
updated_at | 2022-11-10 22:11:29.062474 |
description | Voca_rs is a Rust library for manipulating [unicode] strings |
homepage | |
repository | https://github.com/a-merezhanyi/voca_rs |
max_upload_size | |
id | 84991 |
size | 2,089,652 |
Voca_rs is a Rust library for manipulating [unicode] strings.
Voca_rs is implemented on Foreign Types, i.e. String
and str
. Respects Unicode.
Voca_rs is inspired by Voca.js (JavaScript), string.py (Python), Inflector (Rust), and Grafite (PHP).
Using functions:
use voca_rs::*;
let input_string = "LazyLoad with XMLHttpRequest and snake_case";
let string_in_words = split::words(&input_string);
// => ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"]
let words_in_string = &string_in_words.join(" ");
// => "Lazy Load with XML Http Request and snake case"
let truncated_string = chop::prune(&words_in_string, 21, "");
// => "Lazy Load with XML..."
let sliced_string = chop::slice(&truncated_string, 5, -2);
// => "Load with XML."
let snaked_string = case::snake_case(&sliced_string);
// => "load_with_xml"
Using traits (all methods start from the underscore symbol):
use voca_rs::Voca;
"LazyLoad with XMLHttpRequest and snake_case"
._words()
// => ["Lazy", "Load", "with", "XML", "Http", "Request", "and", "snake", "case"]
.join(" ")
// => "Lazy Load with XML Http Request and snake case"
._prune(21, "")
// => "Lazy Load with XML..."
._slice(5, -2)
// => "Load with XML."
._snake_case();
// => "load_with_xml"
See the complete documentation at https://docs.rs/voca_rs/
Run tests: cargo test
Build docs: cargo doc
-> ./target/doc/voca_rs/index.html
Build a project: cargo build
-> ./target/debug
Coded by A. Merezhanyi
Licensed under MIT License