I’m new to rust so maybe my idea has been proposed before but I didn’t find anything about it so I’m posting it here for discussion:
? operator is very useful but it seems like it could apply not just to
Result but also to
Option and many other types. Actually I think it should apply to every type that implements
and_then (including the futures everyone is talking about).
I think that
let x = y?; z
should be syntactic sugar for
This is already the behavior of
? so it wouldn’t break existing code.
I understand that such a change wouldn’t be easy because the
z of my example may not be easy to isolate and lifetimes can end before the end of the enclosing function but I think these challenges could be overcome.
Was this discussed before and are there good reasons not to do it?