News for hackers. Stuff that matters.
Re:Mistakes with Rust smart pointers: when Deref goes wrong by DixieDev on Monday July 10, 2023 @06:14AM (#36664213)
I'm mostly indifferent to it because it doesn't really harm readability, and it's not hard to know when to use it, but I can seem why it might be more strongly disliked. You can't entirely rely on it to know a dereference is happening because references (e.g. `int&`) aren't subject to the `->` requirement. It's also annoying if you find that you can refactor `func(T*)` to `func(T&)` and now you have to replace all `->`s with `.`s.
Re:Mistakes with Rust smart pointers: when Deref goes wrong by codeflo on Monday July 10, 2023 @06:18AM (#36664240)
> You can't entirely rely on it to know a dereference is happening because references (e.g. `int&`) aren't subject to the `->` requirement.

To the extent that this is a problem, it's a problem with references as a language feature in general, not with the arrow syntax.

Re:Mistakes with Rust smart pointers: when Deref goes wrong by quietbritishjim on Monday July 10, 2023 @11:11AM (#36667585)
> You can't entirely rely on it to know a dereference is happening because references (e.g. `int&`) aren't subject to the `->` requirement.

That's true but I think the bigger motivation is avoiding ambiguity than seeing when an indirection is happening. (You also can't see whether a method is virtual, i.e. indirecting via the vtable, from the call site.) In C++ references don't have any standalone methods or operators so there's no ambiguity from using methods via a reference just using a dot.