TWiR quote of the week

/u/Quxxy on Reddit:

Can you eli5 why TryFrom and TryInto matters, and why it's been stuck for so long ? (the RFC seems to be 3 years old)

If you stabilise Try{From,Into}, you also want implementations of the types in std. So you want things like impl TryFrom<u8> for u16. But that requires an error type, and that was (I believe) the problem.

u8 to u16 cannot fail, so you want the error type to be !. Except using ! as a type isn't stable yet. So use a placeholder enum! But that means that once ! is stabilised, we've got this Infallible type kicking around that is redundant. So change it? But that would be breaking. So make the two isomorphic? Woah, woah, hold on there, this is starting to get crazy...

*new person bursts into the room* "Hey, should ! automatically implement all traits, or not?"

"Yes!" "No!" "Yes, and so should all variant-less enums!"

Everyone in the room is shouting, and the curtains spontaneously catching fire. In the corner, the person who proposed Try{From,Into} sits, sobbing. It was supposed to all be so simple... but this damn ! thing is just ruining everything.

... That's not what happened, but it's more entertaining than just saying "many people were unsure exactly what to do about the ! situation, which turned out to be more complicated than expected".

33 Likes