Closed rosefromthedead closed 1 year ago
Interesting; can you please explain your use case for making a Coproduction of 1 type?
Idk this is the author of effing-mad so if they have a use case, I believe them 🤣
Sorry, I tried to reply this morning, but my email server fell over :)
My API involves generic coproducts, and users* provide functions from a subset of a coproduct to a subset of another - providing multiple functions until all variants are accounted for. If the user wants to deal with only one variant of each, it is more ergonomic for me to provide API surface that does the extracting and injecting around such a function, so the user doesn't have to. These APIs are internally implemented using the more general public API, so my code has a fair few match expressions that do what extract
could do.
*users (hypothetical). No one actually uses it yet :)
Yeah, I used to use unreachable!()
for these cases, until someone sent me a patch to do it this way. I agree that since match never {}
can only be used when it is definitely impossible, it better conveys the semantics of that match arm.
Edit: Good god, I'm never using that email reply thing again. Aside from all the noise it sent and the markdown it didn't apply, this was supposed to be a reply to the thread above :/
I would find it useful :) It's like
.take().unwrap()
but without the implication that it might panic.