A high-performance, type-safe Rust implementation of Lodash collection methods with zero-cost abstractions.
- 🚀 High Performance: Zero-cost abstractions with optimized implementations
- 🔒 Type Safety: Full compile-time type checking and memory safety
- 🔗 Chainable API: Fluent interface for method chaining
- ⚡ Async Support: Optional async/await support for modern Rust
- 🔄 Parallel Processing: Optional parallel iteration with rayon
- 🌐 WASM Compatible: Full WebAssembly support for browser usage
- 📦 No Std Support: Optional
no_stdsupport for embedded systems
Add 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 left
find(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 groups
groupBy(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 element
shuffle(collection)- Randomize element ordersample(collection)- Get random elementsampleSize(collection, n)- Get n random elementssize(collection)- Get collection length
use 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 test
lodash-rs is designed for high performance:
- Zero-cost abstractions: No runtime overhead for method chaining
- Optimized algorithms: Efficient implementations of all operations
- Memory efficient: Minimal allocations and copying
- SIMD ready: Prepared for future SIMD optimizations
- Rust: 1.70+
- Platforms: Windows, macOS, Linux
- Architectures: x86_64, ARM64
- WASM: Full browser support
Contributions are welcome! Please see CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the original Lodash JavaScript library
- Built with modern Rust best practices
- Community feedback and contributions
See CHANGELOG.md for a detailed list of changes.
- Additional collection methods
- Performance benchmarks
- SIMD optimizations
- More async operations
- Enhanced WASM bindings
- Documentation improvements