fera_fun

Function position_min_by_key

Source
pub fn position_min_by_key<I, F, X>(iter: I, f: F) -> Option<usize>
where I: IntoIterator, X: Ord, F: FnMut(&I::Item) -> X,
Expand description

Returns the first position of the minimum element of a non empty iterator or None if iterator is empty.

use fera_fun::position_min_by_key;

assert_eq!(Some(0), position_min_by_key(&[0i32, 3, -5, 0, 5], |x| x.abs()));