Skip to content

Sort-of RFC: add min!, max! macros once namespacing lands #53501

Closed as not planned
@richard-uk1

Description

@richard-uk1

Since you can namespace macros in rust 2018, maybe consider including min and max macros in std::cmp?

From a post about gamedev on rust

There’s no min! and max! macro. You need to write max(max(max(max(max(max, a), b), c), d), e) for example. I have a code with 15 max like this.

This seems like a macro you can write yourself easily enough. Is there something I’m missing?

macro_rules! max {
     ($e: expr) => { $e };
     ($e: expr, $($rest: tt)*) => { max($e, max!($($rest)*)) }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API 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