Is using ? a language or library feature?

I am new to learning rust.
So far my understanding is that the Option is a library feature and most related featurs of Option are possible for other enums as well.

But how does the "?" syntax work for Option being None?

let var = some_api()?

How is the ? syntax specific to a library enum?

1 Like

The ? operator corresponds to the Try trait. Unfortunately it isn't stable, so unless you're using a nightly compiler you can't currently implement it for your own types.


Got it, so it has nothing to do with specifics of Options
It just calls few methods from the Try trait and ends up implementing the current ? functionality that we know of


For more, you can read about it in RFC#3058:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.