3 ms·
Whaat, was this new in 2018 ed? I could've sworn it was `()` and so you couldn't do that. I don't write rust that often, and happen to be reading this just as I
by OJFord 6y ago
Whaat, was this new in 2018 ed? I could've sworn it was `()` and so you couldn't do that. I don't write rust that often, and happen to be reading this just as I've written some code that's.. not that messy but not that I'm pleased with, wrangling around exactly this sort of if-assign-else-return pattern.
- steveklabnik 6y agoI don’t believe it should be new, but this can happen by accident sometimes. Like, if you included a ; on the non-return branch it would return () overall and you probably thought the return did it when it wasn’t that. Hard to say!
- OJFord 6y agoI made exactly that error when I went back to refactor with my new-found knowledge, so I think that must have been it. Thanks, both of you! /facepalm
- steveklabnik 6y agoGlad to hear it!
- orthoxerox 6y ago() is a unit type, it has a single possible value. ! has no possible values.