5 ms·
I still find the second case far more readable. When you see "try{}" it says "this is here because I want to turn on ?-handling within this block". When you s
by octoberfranklin 6y ago
I still find the second case far more readable.
When you see "try{}" it says "this is here because I want to turn on ?-handling within this block".
When you see a closure formed and then immediately applied it says... well I dunno. Frankly it seems to say "this expression should be simplifiable". In fact it's a huge wart on Rust that beta-reduction doesn't preserve well-formedness of expressions.
Also if there were more stuff in the expression body it might not even be obvious at a glance that the closure is being formed-and-then-immediately-invoked, leading a reviewer to wonder "wtf is a closure doing here?".
- Arnavion 6y agoOh yes, my point was not that the try-blocks version was less readable. I agree that it's better and used to use it back when it was still called `do catch { }` and didn't do automatic-Ok-wrapping. I was just making the comparison fairer.