3 ms·
Maybe "by the type system" was the wrong way to say that. What I meant is that if I wanted to write my own Result, say Result2, it wouldn't be included in the q
by _bxg1 7y ago
Maybe "by the type system" was the wrong way to say that. What I meant is that if I wanted to write my own Result, say Result2, it wouldn't be included in the question mark syntax. Perhaps I could write a macro for it, I guess, but the real one is not implemented as a macro and if I wanted to go use my knowledge of the language fundamentals to read the standard library and figure out what it does, I couldn't do that. It just is that way.
- ChrisSD 7y agoThis is being worked on. See the Try trait in std::ops. It's implemented for Result, Option and Poll (the `try!` macro only ever worked with Result). Implementing it for your own types is currently unstable because sorting out all the edge cases is proving to be difficult. But the intent is definitely to stabilize it once a good general solution is found.
- _bxg1 7y agoThat's good to know. And I suppose there are other cases where "special language features" can be hooked into via the (wonderful) traits system, like Drop, so I guess that does go some way toward relieving the sting of having magical syntaxes.