Repeated `return type` could be removed from function body

As much as I do believe your ideas for improving Rust seem genuine and not stupid, I do believe they show you might want to familiarize yourself a little bit more with the language; your ideas ([1][2]) seem to focus very much on issues of surface syntax, and do little to improve the problems that more experience users of Rust might have with the language. With experience in a programming language, one’s views of what does “look elegant” also often changes.

Yes, Rust iterators can be more verbose than functional programming; yes Rust can be more explicit in types than other languages with even more type inference capability.

But whenever you notice “this seems redundant” about some syntax, you need to consider the bigger picture. How much of an issue is a little bit of extra typing really? Was there any reason why it was required in the first place? Like… does it follow more general principles that would need to change?[1] How much of a new set of general principles could you make out of any feature that do changes them, and how much complexity might this add?[2] Do slightly modified versions of the code exist where the information isn’t redundant – then perhaps it wasn’t fully redundant in the original code either?[3]


  1. If you aren’t sure why something is the way it is, a good first step could also be to ask on the Users Forum for feedback on why things are designed the way they are. If people list good reasons and explain underlying design principles you weren’t aware of, maybe it was a great learning opportunity; and if people express that “it’s tedious / it’s the way it is / wish Rust had a better way for this” it can be great motivation to spend some actual effort into finding and fleshing out concrete ideas for improvement that don’t have zero change to ever lead anywhere to begin with ↩︎

  2. E.g. how much special-case magic would you need? E.g. for StructName { field: value }-style syntax, becoming { field: value } what about the case of StructName {}? Because {} already has a clear (and different!) meaning! ↩︎

  3. For example, with your iterators ideas, note how collect can create collections of other types than you started with. ↩︎

19 Likes