Open richard-uk1 opened 6 years ago
Since you can namespace macros in rust 2018, maybe consider including min and max macros in std::cmp?
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)*)) } }
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)*)) } }
Doesn't seem like a big enough change for an RFC, whether it gets accepted or not.
Don't forget to make it trailing-comma-accepted: $(,)? with the kleene op or just another arm if not.
$(,)?
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