Hacker News new | ask | show | jobs
by comex 4379 days ago
FWIW, I am a big fan of easy to read code (as I frequently need to read other people's code in order to 'audit' it). But like others have said, in real Rust code the ability to mix blocks and expressions does not seem particularly confusing to me, and is used in many places other than the end of a function, in more of a functional style. Here is a representative-ish example:

https://github.com/rust-lang/rust/blob/master/src/librustc/m...

Personally I think most other things in Rust (namespaces, constant as_slice() unwrap() etc.) are currently too verbose, although I'd say that also impedes readability.

2 comments

Hah, I would caution against looking into the depths of rustc for examples of good examples of rustic code. Many parts of the compiler have changed very little from the original bootstrapping from OCaml, and have only been incrementally updated since then. No doubt it will eventually be cleaned up, but it will be a big effort.

I do agree with the rest of your first paragraph though.

librustc isn't a very good example of showing, since it's not idiomatic Rust and a mixture of previous iterations.