Reputation: 434
The question mark operator (?) is defined for Option and Result types. Is it possible to overload it for some custom type? I haven't found any trait that might guide this behavior.
Upvotes: 9
Views: 2435
Reputation: 7927
The trait you're looking for is called std::ops::Carrier
. However as you can see it's experimental and it caused lots of discussions on how to implement it (I believe it's experimental for a few years already).
So technically you may use it, but you better don't rely on it as its look might be changed or it can be removed for good.
Upvotes: 5