I posted to Reddit a while back about the
? operator and the
Option type, wherein I learned this is a valid but somewhat under documented thing to do in Rust.
I’m trying to get to Swift-like semantics, where it’s easy to traverse a chain of
? as a quasi-monadic operator.
Alas, it’s not so easy in Rust b/c ownership. As an example, the following playground provides two function definitions which I’d expect to be equivalent but are not:
I suspect the difference between the two is my use of
ref h. The following example demonstrates a similar set of issues to the
? operator although the exact errors are different:
I don’t know if this is a bug with the
? operator, or an expected limitation of the operator, or something else entirely. I suspect defining
? in terms of reference taking might address my issue, but it might well cause others that I’m completely blind to.
BTW, the error suggesting
&'a mut self is a complete red herring.