min_max
Returns the smallest and largest item of iter in one pass, or None when it is empty.
Equivalent to calling
.min() and
.max() separately, but
only iterates once, so it also works on an iterator that can only be consumed a single time.
Comparisons follow T’s PartialOrd: with f64, a NaN is neither smaller nor larger
than anything, exactly as < and > say, so a NaN that is never replaced (for instance the
very first item) stays in the result.
Import
Section titled “Import”Cargo feature iter (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
iter | impl IntoIterator<Item = T> | The items to scan. |
Returns
Section titled “Returns”Option<(T, T)> — (min, max), or None when iter is empty.
