iter-first-max 0.1.2

Iterator::max* returns the last for equal keys, this crate implements the return the first
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented3 out of 9 items with examples
  • Size
  • Source code size: 4.37 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 726.93 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • A4-Tacks/iter-first-max-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • A4-Tacks

Iterator::max* returns the last for equal keys, this crate implements the return the first

use iter_first_max::IterFirstMaxExt as _;

let arr = [(0, 0), (1, 1), (2, 2), (2, 3), (2, 4)];
let last  = arr.iter().max_by_key(|n| n.0);
let first = arr.iter().first_max_by_key(|n| n.0);

assert_eq!(last,  Some(&(2, 4)));
assert_eq!(first, Some(&(2, 2)));