News for hackers. Stuff that matters.
Re:Never patterns, exhaustive matching, and uninhabited type... by the_mitsuhiko on Saturday August 18, 2018 @09:33AM (#17788371)
A string is the worst thing to return because it’s huge. Most people return () instead which is zero sized.

However when returning ! the compiler can optimize the entire error handling away.

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.
Re:Never patterns, exhaustive matching, and uninhabited type... by fnord123 on Sunday August 19, 2018 @04:45AM (#17793318)
A string is only like 16bytes (length + pointer to memory in heap) or more if it's a fat pointer.