Repository navigation
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629S-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.Status: The implementation is "complete" but it needs time to bake.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
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.)
- ACP: ACP: Variadic
core::cmp::{min, max}libs-team#848 - Implementation: Experiment: Add
core::cmp::smallestandcore::cmp::largest#160687 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should we replace
minandmax(and their_by(_key)alternatives), or offer these new functions under a separate name?
Footnotes
Reacted by teor and Ben Hull
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629S-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.Status: The implementation is "complete" but it needs time to bake.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Activity
Rollup merge of rust-lang#160687 - bushrat011899:experiment_splat_min…
Unrolled build for #160687
Rollup merge of rust-lang#161275 - bushrat011899:variadic_min_refacto…
Unrolled build for #161275 in rollup 163244
Rollup merge of #161275 - bushrat011899:variadic_min_refactor, r=scot…
Rollup merge of rust-lang#161275 - bushrat011899:variadic_min_refacto…