2 ms·
Some corrections: * option and result are also available in C++, the former is even standardised. * random numbers support is quite good. * C++ compilers wil
by blub 9y ago
Some corrections:
* option and result are also available in C++, the former is even standardised.
* random numbers support is quite good.
* C++ compilers will warn if not all members of an enum have been handled in a switch. It's also easy to assert/throw in the default case as a safety measure.
* tuples are likewise supported
* I believe something like your opaque types could be done with templates and tag classes in a similar amount of LOC.
But yes, in Rust it's generally easier to do the right thing. This is the big benefit of learning from others' mistakes and not having to maintain backwards compatibility with ancient decisions.
- Manishearth 9y agostd::optional don't enforce exhaustiveness; you can get away with accidentally unwrapping it. In Rust this requires an explicit check or explicit call to unwrap()/expect(). To me, this is super important. But yeah, it's still a good thing to have! IIRC there are TMP-implemented versions of this that are safer (though a bit ugly to use) though.