News for hackers. Stuff that matters.
Re:Rust Traits Deep Dive, Part 2 by steveklabnik on Wednesday June 20, 2018 @09:01AM (#17354931)
Tiny, tiny addendum here:

> a + b is (always) equivalent to Add::add(a, b)

method call synatx does auto ref/deref, so it may be

Add::add(&mut a, b)

or

Add::add(&a, b)

too, etc.

Re:Rust Traits Deep Dive, Part 2 by dbaupp on Wednesday June 20, 2018 @09:34AM (#17355165)
Yep! That's why it's equivalent to Add::add(a, b), not a.add(b). (This was definitely something I had to check, though, and, as you say, a tiny detail that's almost certainly irrelevant to most code that people write.)
Re:Rust Traits Deep Dive, Part 2 by chrismorgan on Wednesday June 20, 2018 @09:40AM (#17355213)
Ah, the old days when operators worked by reference… it was much harder to express precisely what the + sugar was back then.
Re:Rust Traits Deep Dive, Part 2 by steveklabnik on Wednesday June 20, 2018 @09:37AM (#17355186)
See my response to Chris, I actually thought it was! My bad!
Re:Rust Traits Deep Dive, Part 2 by chrismorgan on Wednesday June 20, 2018 @09:31AM (#17355141)
Method call syntax does, but operators don’t.
Re:Rust Traits Deep Dive, Part 2 by steveklabnik on Wednesday June 20, 2018 @09:36AM (#17355183)
Ah ha, I didn't realize that. I thought it desugared to the method call, which then gets de-sugared to the fully qualified syntax. That does seem more complicated than skipping the intermediate step, and since we have so many implementations for the various ref or not'd version, it ends up feeling the same. Thanks!