> - It has powerful generics and macros, so people who want to write really clever code, can.
To take a cue from the article: how do you write a generic max() function for an arbitrary number of arguments?
Re:My gamedever wishlist for Rust
by nemothekid on Thursday October 01, 2015 @03:42PM
(#10314098)
Someone had commented this in a response on the site.
macro_rules! max {
($e: expr) => { $e };
($e: expr, $($rest: tt)*) => { max($e, max!($($rest)*)) }
}
It does seem strange, because:
- It has constructs which aren't present in C/C++ in the exact form, like traits or pattern matching (maybe it'd be easier if they were called templates and switch, but they're not quite the same thing, so a different name is good). There's a lot of Rust-specific jargon for things that aren't as complicated as they seem.
- Some constructs (e.g. enums and empty structs) look like C's, but again aren't quite the same.
- It has powerful generics and macros, so people who want to write really clever code, can.