Function sknife::collection::find [] [src]

pub fn find<T, F, I>(predicate: F, list: I) -> Option<T> where
    F: FnMut(T) -> bool,
    I: Iterator<Item = T>,
    T: Clone

Find first element of list that satisfies a predicate

Arguments

  • predicate - The predicate function
  • list - A list of elements to find in

Example

use sknife::collection::find;
let list = vec![1, 2, 3, 4];
let greater_than_one = |x: i32| x > 1;
find(greater_than_one, list.into_iter());
 

Result

2;