Hacker News new | ask | show | jobs
by MichaelGG 3625 days ago
But that's actually longer. It does look a bit better though, maybe.
1 comments

Yeah, it's not about saving characters to me, it's about clarity.
Actually, this suggestion does not even work. Writing trait::method is not equivalent to writing "|x|x.method()". The latter will use method lookup rules, the former requires the programmer to decide which impl. For instance, in the above example, if the type impl'd to_string, that would be the one used, not ToString's implementation. From what I can tell anyways: https://is.gd/E8pdWc

Edit: Also, auto-borrow does not seem to work with this syntax.

This is a common enough pattern that reducing the visual noise will increase clarity.

Yes, this is correct. It's what I was getting at in the other thread; this is choosing a method manually.