I think that deref should be called a minimal number of times. At least with immutable references that means: at most once. For mutable ones you may need an immutable deref followed by a mutable one. Compare this comment:
I also think a maximally ergonomic solution, potentially without keywords, sounds like a good idea. We should however try to flesh out the details of such an approach in order to be able to really evaluate it. One thing that comes to mind just now is: Wouldn't it be surprising if
match &whatever {
Ok(foo) => { /* … */ }
bar => { /* … */ }
}
resulted in foo
being &T
whereas bar
still is &SmartPointer<Result<T, E>>
? With current reference-only ergonomics, we have the much more consistent situation of bar
always being &Result<T, E>
.