lo_-0.2.2 has been yanked.
Lo_ as Lodash โ
A modern Rust utility library delivering modularity, performance & extras ported from JavaScript Lodash
Installation
Add lo_ to your Cargo.toml:
[]
= { = "0.2.2", = ["transform", "async_retry"] }
Or run the following command:
Usage Examples
๐งต String Manipulation Utilities
Basic Case Conversions
For quick use, you can import and call built-in helpers like camel_case, snake_case, etc., without needing the trait:
use camel_case;
let input = "Foo Bar";
let result = camel_case;
println!; // "fooBar"
Use the Transform trait for chainable and expressive string utilities:
use Transform;
let s = "HelloWorld";
println!; // "hello_world"
println!; // "helloWorld"
println!; // "Hello World"
println!; // "helloWorld"
println!; // "HelloWorld"
let input = "fred, barney, & pebbles";
println!; // ["fred", "barney", "pebbles"]
println!; // "rust-is-awesome"
let num: = "123".to_safe_parse;
println!; // Some(123)
Word Wrapping
use Transform;
let text = "Rust is blazing fast and memory-efficient.";
let wrapped = text.wordwrap;
println!;
/*
Rust is
blazing
fast and
memory-efficient.
*/
Padding
use ;
let s = "42";
assert_eq!;
assert_eq!;
assert_eq!;
Word Extraction
use Transform;
let s = "Hello world, this is Rust!";
let words = s.to_words;
assert_eq!;
String Templating
use HashMap;
use Transform;
let mut data = new;
data.insert;
data.insert;
let template = "Hi {{name}}, welcome to {{lang}}!";
let rendered = template.to_template;
assert_eq!;
๐ฆ Collection Utilities
use ;
let array = vec!;
let size = 3;
let chunks = chunk;
println!; // array chunks: [[1, 2, 3], [4, 5, 6], [7]]
let numbers = vec!;
let is_even = ;
println!; // Some(2)
let input = vec!;
let output = uniq;
println! // [2, 1]
โ๏ธ General Utilities
use retry;
use Duration;
let mut count = 0;
let result = retry;
println!; // Ok("success") after 3 retry