In the docs for position_max it is stated:
If several elements are equally maximum, the position of the last of them is returned.
I encountered a problem where I would need something like position_first_max, which returns index/position of the first max value.
And same goes for position_min. Stated:
If several elements are equally minimum, the position of the first of them is returned.
So my question is: should we add position_first_max and position_last_min, which correspondingly return index/position of first max value and index/position of last min value?
If yes I can try making pull request, though I'm not very experienced with Rust.
Usage example:
// index 0 1 2 3 4 5 6 7 8
let arr = [3, 0, 4, 9, 5, 9, 6, 0, 7];
assert_eq!(Some(5), arr.iter().position_max());
assert_eq!(Some(3), arr.iter().position_first_max());
assert_eq!(Some(1), arr.iter().position_min() );
assert_eq!(Some(7), arr.iter().position_last_min() );