Skip to content

Tracking Issue for cmp_splat (Variadic min and max) #160728

Open

Description

@bushrat011899

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

  • Should we replace min and max (and their _by(_key) alternatives), or offer these new functions under a separate name?

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Aug 7, 2026
  2. added
    F-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629
    on Aug 9, 2026
  3. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
  4. added a commit that references this issue on Aug 13, 2026
  5. added a commit that references this issue on Aug 13, 2026
  6. added
    S-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.
    and removed on Aug 17, 2026
  7. added a commit that references this issue on Sep 24, 2026
  8. added a commit that references this issue on Sep 24, 2026
  9. added a commit that references this issue on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-splat`#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629S-tracking-needs-to-bakeStatus: 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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions