Rust has a syntax called "turbofish" for disambiguating ambiguous generic calls. (Coined by Anna Harren on twitter, the first reply is an illustration from Karen Rustad Tölva, the inventor of Ferris [1]).
Although Vec is generic over any item type, you can normally just write
let foo = Vec::new();
If you're doing something complicated where the compiler can't infer the type, you instead use the turbofish syntax let foo = Vec::<u32>::new();
Some people hate this syntax. One of the better arguments I've seen against it comes (I think) from ManishEarth, who points out that it's very hard for the compiler to detect that incorrect attempts at writing a turbofish are in fact attempts at the turbofish and offer help.That test case (minus some excellent poetry) is
let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated");
let _: (bool, bool) = (oh<woe, is>(me));
That is actually comparing the string "the" against the string "Turbofish" and the string "remains" against the string "undefeated". The test case is there to point out that if the "::" in the turbofish is removed (Vec<u32>::new() instead of Vec::<u32>::new()) there will be cases where it's ambiguous.[1] https://twitter.com/whoisaldeka/status/914914008225816576?la...
EDIT: Fix my misspelling of ManishEarth
https://github.com/rust-lang/rfcs/pull/2527#issuecomment-414...
It wasn't until that NYT (or whichever paper) interview with 'Dan G[...] HN moderator' that it clicked.
(I still frequently hear it wrong in my head. Habits..)
You raise a good point. I've had a few emails addressing me 'OJ' Ford, which is beyond reasonable in hindsight, just not something I foresaw or that anyone's ever called me in person! Perhaps I unwittingly contributed to that by registering my username mildly against the cultural grain.. :)
Yours,
O. Johnson-Fsmith
Operational Research Department
Over the years, many have mistook my account for that of Sam Altman (sama), or presumed it to be a parody thereof.
In my defense, I have been using this handle, and variants of it, for longer than he's been alive.
Best, (Maha) Sam Atman "you can choose your friends but not your namesake"
I do wonder, if the whitespace (or lack thereof) was mandatory, could this be resolved? What would be the impact of comparisons needing whitespace?