Interesting. I also like the idea of being able define nested enums. Possible syntax:
enum Foo {
Bar,
Wow,
enum Smeg {
Flim,
Flam,
},
}
let x: Foo::Smeg = Foo::Smeg::Flam;
let y: Foo = x;
I don’t know why you’d assume such a poor implementation of this idea. The
third level of OpenFileError is NotFoundError which distinguishes between
cases like path/to/file not being openable because to isn’t a directory or
because the whole file name was too long. I find it hard to imagine cases where
people would actually care about this distinction. Either way you’re
clearly just dealing with an incorrect file name.
I find it easy to imagine scenarios where people want to recovery from UDP
“destination unreachable” errors though. Like, whenever you’re using a UDP
socket to talk to more than one host but you don’t want to crash if one of the
hosts is down. That seems like a very typical use case for UDP actually.
The idea is to divide and organize errors based on how people are likely to want
to respond to them. UdpSocket::recv_from errors which don’t mean your socket
has become unusable - and after which you can just call recv_from again to
keep receiving packets - seem like a top-level category to me.
I was under the impression that tokio could handle 1,000,000 concurrent
tasks.
You can’t think of examples of where programs might want to use all the
resources available? I’m not saying users shouldn’t raise those limits, but
maybe sometimes it’s best for the program to slow down and notify the user
rather than just crashing.
No, but they return something useless, type-wise. To quote myself:
If HashMap::get returned Result<&T, io::Error> do you think people would
reliably handle the case where an entry is missing? Because I think lots of
people would either (a) completely neglect this edge case in their code and
end up throwing io::Errors up the stack instead of doing whatever they should
have done …
Doesn’t this sound a lot like Python? Where you’re not forced to consider the
case where an entry is missing and instead you just end up throwing a
KeyError up the stack?
Yes, the second one does. The form of the error guides people in how to handle
it. That’s kinda my whole point.