Feature gate: #![feature(cmp_splat)]
Zulip: #t-libs-api/api-changes > variadic min/max
This is a tracking issue for variadic cmp::min and cmp::max functions. Currently, these are separate functions named smallest and largest. To allow variadic support, #![feature(splat)] is enabled in core. See #153629 for further details.
Public API
// core::cmp
// Private implementation detail
impl(self) const trait TupleReduce: Tuple {
type Item;
fn reduce<F: [const] Destruct + [const] FnMut(Self::Item, Self::Item) -> Self::Item>(self, f: F) -> Self::Item;
}
impl<T> TupleReduce for (T, ...) { /* ... */ }
#[must_use]
pub const fn smallest<T: [const] Ord + [const] Destruct>(
#[rustc_splat] vals: impl [const] TupleReduce<Item = T>,
) -> T;
#[must_use]
pub const fn largest<T: [const] Ord + [const] Destruct>(
#[rustc_splat] vals: impl [const] TupleReduce<Item = T>,
) -> T;
Note that with #[rustc_splat], the signature of smallest and largest is any of fn(T) -> T through to fn(T, T, ..) -> T (up to twelve arguments). Twelve has been chosen as an arbitrary limit and can be changed.
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
Unresolved Questions
Feature gate:
#![feature(cmp_splat)]Zulip: #t-libs-api/api-changes > variadic min/max
This is a tracking issue for variadic
cmp::minandcmp::maxfunctions. Currently, these are separate functions namedsmallestandlargest. To allow variadic support,#![feature(splat)]is enabled incore. See #153629 for further details.Public API
Note that with
#[rustc_splat], the signature ofsmallestandlargestis any offn(T) -> Tthrough tofn(T, T, ..) -> T(up to twelve arguments). Twelve has been chosen as an arbitrary limit and can be changed.Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)core::cmp::{min, max}libs-team#848core::cmp::smallestandcore::cmp::largest#160687Unresolved Questions
minandmax(and their_by(_key)alternatives), or offer these new functions under a separate name?Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩