Add {min,max}_set(_by{_key)?)? functions (4) use internal iteration
We may relax this bound at some point, but I'd go with this until we
have evidence that it bothers users, as there have been cases where I
actually was happy to be informed about Ord vs PartialOrd.
@@ -14,7 +14,7 @@ pub fn min_set_impl<I, K, F, L>(mut it: I,
}
};
- for element in it {
+ it.for_each(|element| {
let key = key_for(&element);
if lt(&element, &result[0], &key, &current_key) {
result.clear();
@@ -23,7 +23,7 @@ pub fn min_set_impl<I, K, F, L>(mut it: I,
} else if !lt(&result[0], &element, &current_key, &key) {
result.push(element);
}
- }
+ });
result
}
