Closed
Description
There has been a constant stream of confusion relating to the interaction between auto-deref and various overloaded operators, particularly Eq
(e.g., #6257). I think we ought to define the binary operator traits using an associated fn, not a method. This would side-step any issues around autoderef, and also helps to make the method resolution clearer.
For example, Eq
would be define as follows:
trait Eq {
fn eq(a: &Self, b: &Self);
}
meaning that x==y
would be expanded to:
Eq::eq(&x, &y)
The same would apply to other binary operator traits.
Metadata
Metadata
Assignees
Labels
No labels