| Crates.io | rust-lodash |
| lib.rs | rust-lodash |
| version | 0.1.0 |
| created_at | 2025-10-19 16:56:30.104973+00 |
| updated_at | 2025-10-19 16:56:30.104973+00 |
| description | A high-performance, type-safe Rust implementation of Lodash collection methods with zero-cost abstractions |
| homepage | https://github.com/royalwang/rust-lodash |
| repository | https://github.com/royalwang/rust-lodash |
| max_upload_size | |
| id | 1890619 |
| size | 235,450 |
A high-performance, type-safe Rust implementation of Lodash collection methods with zero-cost abstractions.
no_std support for embedded systemsAdd this to your Cargo.toml:
[dependencies]
rust-lodash = "0.1.0"
use rust_lodash::prelude::*;
// Basic operations
let doubled = map(&[1, 2, 3, 4], |x| x * 2);
assert_eq!(doubled, vec![2, 4, 6, 8]);
// Chainable operations
let result = chain(&[1, 2, 3, 4, 5])
.filter(|x| x % 2 == 0)
.map(|x| x * 3)
.collect();
assert_eq!(result, vec![6, 12]);
// Collection operations
let numbers = vec![1, 2, 3, 4, 5];
let evens = filter(&numbers, |x| x % 2 == 0);
let sum = reduce(&numbers, |acc, x| acc + x, 0);
[dependencies]
rust-lodash = { version = "0.1.0", features = ["async"] }
use rust_lodash::prelude::*;
// Async operations (requires async feature)
// let async_result = map_async(&[1, 2, 3], |x| async move { x * 2 }).await;
// assert_eq!(async_result, vec![2, 4, 6]);
[dependencies]
rust-lodash = { version = "0.1.0", features = ["parallel"] }
use rust_lodash::prelude::*;
// Parallel operations (requires parallel feature)
// let result = map_parallel(&[1, 2, 3, 4], |x| x * 2);
// assert_eq!(result, vec![2, 4, 6, 8]);
[dependencies]
rust-lodash = { version = "0.1.0", features = ["wasm"] }
map(collection, iteratee) - Transform each elementfilter(collection, predicate) - Filter elements by conditionreduce(collection, iteratee, initial) - Reduce to single valueforEach(collection, iteratee) - Execute function for each elementforEachRight(collection, iteratee) - Execute function from right to leftfind(collection, predicate) - Find first matching elementfindLast(collection, predicate) - Find last matching elementincludes(collection, value) - Check if value existsevery(collection, predicate) - Check if all elements matchsome(collection, predicate) - Check if any element matchescountBy(collection, iteratee) - Count elements by keypartition(collection, predicate) - Split into two groupsgroupBy(collection, iteratee) - Group elements by keykeyBy(collection, iteratee) - Create object with keyssortBy(collection, iteratee) - Sort elements by keyorderBy(collection, iteratee, descending) - Sort with directioninvoke(collection, method) - Invoke method on each elementshuffle(collection) - Randomize element ordersample(collection) - Get random elementsampleSize(collection, n) - Get n random elementssize(collection) - Get collection lengthuse rust_lodash::chain;
let result = chain(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
.filter(|x| x % 2 == 0) // [2, 4, 6, 8, 10]
.map(|x| x * 3) // [6, 12, 18, 24, 30]
.take(3) // [6, 12, 18]
.reverse() // [18, 12, 6]
.collect(); // Vec<i32>
See the examples/ directory for more detailed usage examples:
basic_usage.rs - Comprehensive examples of all featuresstandalone_test.rs - Simple functionality testlodash-rs is designed for high performance:
Contributions are welcome! Please see CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a detailed list of changes.