| Crates.io | iter-first-max |
| lib.rs | iter-first-max |
| version | 0.1.2 |
| created_at | 2025-07-17 14:44:13.428116+00 |
| updated_at | 2025-07-23 01:02:06.228369+00 |
| description | Iterator::max* returns the last for equal keys, this crate implements the return the first |
| homepage | |
| repository | https://github.com/A4-Tacks/iter-first-max-rs |
| max_upload_size | |
| id | 1757608 |
| size | 4,876 |
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)));