| Crates.io | zombie_utils |
| lib.rs | zombie_utils |
| version | 0.0.4 |
| created_at | 2025-12-22 09:02:31.822865+00 |
| updated_at | 2025-12-24 18:16:41.19964+00 |
| description | Utility functions and combinators for zombie-rs (bindN, sequence, zip, traverse, etc.) |
| homepage | |
| repository | https://github.com/kawayww/zombie-rs |
| max_upload_size | |
| id | 1999367 |
| size | 33,540 |
Utility functions and combinators for zombie-rs.
This crate provides ergonomic APIs for working with Zombie values:
zbind!(|x, y| x+y, a, b)bind2 - bind23): Syntactic sugar for nested bind/map operationssequence, zip, zip_with, traverseZombieExt for fluent method chaininguse zombie_rs::prelude::*;
use zombie_utils::prelude::*;
fn main() {
Runtime::init();
let a = Zombie::new(1);
let b = Zombie::new(2);
let c = Zombie::new(3);
// Using zbind! (Recommended)
let sum = zbind!(|x, y, z| x + y + z, a.clone(), b.clone(), c.clone());
assert_eq!(sum.get(), 6);
// Using bind3
let sum = bind3(a.clone(), b.clone(), c.clone(), |x, y, z| x + y + z);
assert_eq!(sum.get(), 6);
// Using zip (extension method)
let pair = a.clone().zip(b.clone());
assert_eq!(pair.get(), (1, 2));
// Using sequence
let items = vec![Zombie::new(1), Zombie::new(2), Zombie::new(3)];
let collected = sequence(items);
assert_eq!(collected.get(), vec![1, 2, 3]);
// Using traverse
let doubled = traverse(vec![1, 2, 3], |x| Zombie::new(x * 2));
assert_eq!(doubled.get(), vec![2, 4, 6]);
}
// Combine 2-23 Zombie values with a function
let result = bind2(a, b, |va, vb| va + vb);
let result = bind3(a, b, c, |va, vb, vc| va + vb + vc);
// ... up to bind23
// Convert Vec<Zombie<T>> to Zombie<Vec<T>>
let combined = sequence(vec![z1, z2, z3]);
// Combine two Zombies into a tuple
let pair = zip(a, b); // Zombie<(A, B)>
// Combine with a function
let sum = zip_with(a, b, |x, y| x + y);
// Apply function to each element
let results = traverse(items, |x| Zombie::new(process(x)));
use zombie_utils::ZombieExt;
let result = a.zip(b); // Same as zip(a, b)
let result = a.zip_with(b, f); // Same as zip_with(a, b, f)
let result = a.filter(|x| *x > 0);
let result = a.filter_map(|x| some_option(x));
let result = a.zip3(b, c); // Zombie<(A, B, C)>
MIT