find_all

Crates.iofind_all
lib.rsfind_all
version2.0.0
sourcesrc
created_at2022-06-27 09:59:34.876914
updated_at2022-06-29 17:58:30.903198
descriptionA (nearly) identical alternative for `Iterator::find` which returns an `Option>` containing all elements which meet a given predicate (instead of just the first)
homepage
repositoryhttps://github.com/nectariner/find_all
max_upload_size
id614042
size4,256
nectarine (nectariner)

documentation

README

find_all

find_all is capable of finding all indexes of elements where a given predicate is met and therefore aims to be a simple alternative with (nearly) identical interface to the find method (this difference being returning an Option<Vec<usize>> instead of Option<usize>)

use find_all::FindAll;
let test_data = [1, 2, 3, 4, 1, 1, 1, 1];
let indexes = test_data.iter().find_all(|num: &&i32| **num == 9);
assert_eq!(indexes, None);

let indexes = test_data.iter().find_all(|num: &&i32| **num == 1);
assert_eq!(indexes, Some(vec![0,4,5,6,7]));

License: GPL-3.0-only

Commit count: 9

cargo fmt