Re:Never patterns, exhaustive matching, and uninhabited type...
by masklinn on Saturday August 18, 2018 @12:13PM
(#17789143)
> A string is the worst thing to return because it’s huge. Most people return () instead which is zero sized.
I think what they're asking is "if you're returning a Result<String, Err>" but you're making the Err an unhinabitated type (so can't ever have an error) why not just return a String in the first place?
Re:Never patterns, exhaustive matching, and uninhabited type...
by the_mitsuhiko on Saturday August 18, 2018 @02:14PM
(#17789747)
Because there are generic APIs that return results as part of the contract. A good example is FromStr.
However when returning ! the compiler can optimize the entire error handling away.