Why does += require manual dereference when AddAssign() does not?

I've been confused about that line for approximately :infinity:, but that's not what it means.

Deref coercion definitely still works on the receiver using fully qualified syntax. And for DerefMut too.

I think this is more a matter of trait impl resolution.


More generally, I've learned to be skeptical when the documentation says operator X is the same as method call Y. Operator lookup is it's own underdocumented distinct thing from both method calls and method dispatch; as far as I'm aware, there's no desugaring that universally works for at least some operators.

That said, I haven't find a particular counter example for this case (AddAssign).

3 Likes