4 ms·
But that's actually longer. It does look a bit better though, maybe.
by MichaelGG 10y ago
But that's actually longer. It does look a bit better though, maybe.
- steveklabnik 10y agoYeah, it's not about saving characters to me, it's about clarity.
- MichaelGG 10y agoActually, 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 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.
- steveklabnik 10y agoYes, this is correct. It's what I was getting at in the other thread; this is choosing a method manually.