reject

Function reject 

Source
pub fn reject<'a, T, F>(collection: &'a [T], predicate: F) -> Vec<&'a T>
where F: Fn(&'a T, usize) -> bool,
Expand description

Reject items from a collection that satisfy a predicate.

This function iterates over a collection and returns a new vector containing all items for which the predicate returns false.

§Arguments

  • collection - A slice of items.
  • predicate - A function that takes an item and its index, returning a boolean.

§Returns

  • Vec<&T> - A vector of references to items that do not satisfy the predicate.

§Examples

use lowdash::reject;
let numbers = vec![1, 2, 3, 4, 5];
let result = reject(&numbers, |x, _| *x % 2 == 0);
assert_eq!(result, vec![&1, &3, &5]);