pub fn partition<T, F>(items: Vec<T>, predicate: F) -> (Vec<T>, Vec<T>)Expand description
Partition a vector into two vectors based on a predicate. Returns (matching, non_matching).
ยงExamples
use chie_shared::partition;
// Separate even and odd numbers
let numbers = vec![1, 2, 3, 4, 5, 6];
let (evens, odds) = partition(numbers, |n| n % 2 == 0);
assert_eq!(evens, vec![2, 4, 6]);
assert_eq!(odds, vec![1, 3, 5]);
// Filter strings by length
let words = vec!["hi", "hello", "bye", "goodbye"];
let (long, short) = partition(words, |w| w.len() > 3);
assert_eq!(long, vec!["hello", "goodbye"]);
assert_eq!(short, vec!["hi", "bye"]);