The about section of the linked page has links and a brief explanation of the story.

In my own words …

Description of the Turbo-fish syntax

  • Whenever a generic type (see ch 10 of The Book) is involved in calling a function/method or constructing/handling a struct/enum, you may need to specify that concrete type for that generic.
  • This type is provided with the turbo fish syntax: ::<> … where the type goes between the angle brackets.
  • EG:
let v = Vec::new();

let v2 = Vec::<i32>::new()
  • The elements of v have an undefined type, which rust will infer once an element is pushed into it. But v2 has a defined element type, i32, defined using the turbo fish.

The Story

  • This syntax wasn’t always liked, and the double colons (::) thought redundant.
  • But it stuck
  • And was given the name “turbo-fish” by Anna Harren (u/deadstone, Reddit) … who sadly passed away in 2021.
  • It turns out that the double colons are pretty vital to preventing ambiguity.
  • This is enshrined in the Bastion of the Turbofish which stands as a memorial to Anna Harren …
  • a test in the language’s test suite that ensures that the double-colons syntax isn’t removed by directly using the ambiguous syntax that’d arise without it.
  • See if you can understand the test (it took me a while! … this HN post might help):
let (the, guardian, stands, resolute) = ("the", "Turbofish", "remains", "undefeated");
let _: (bool, bool) = (the<guardian, stands>(resolute));

hint: what are angle brackets normally used for and how are bool types related to that?

  • sorrybookbroke@sh.itjust.worksM
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 months ago

    It’s been a bit but I would like to thank you for this post. That’s a very interesting read, I always love to get a glimpse at why things are howbthey are in a language.

    I still don’t see a fish though. For this I am ashamed

    • maegul (he/they)OPM
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 months ago

      I still don’t see a fish though. For this I am ashamed

      Haha … you have to squint maybe! Coming up with the name turbofish was probably low key genius!