chrisphan.com

Turbofish

An analog clock reading 4:002025-01-13 / 2025-W03-1T16:00:00-06:00 / 0x67858ce0

Categories: computers, fun, programming, Internet culture

Today, I found this really cool site: turbo.fish

The turbofish is a strange-looking piece of syntax in the Rust programming language. It takes the form ::<Foo>, and is used to convey type information to the compiler. Consider line 559 of the following (taken from the program I currently use to produce this site):

src/code_highlight.rs Rust

                let lineno_start: Option<usize> = match specs.get(2) {
                    Some(&"") => None,
                    Some(w) => w.parse::<usize>().ok(),
                    None => None,
                };

The turbofish ::<usize> on line 559 tells the compiler that we want to attempt to parse the string slice w as a usize (pointer-sized unsigned integer).

I was aware of this terminology, but not its origin. As explained on the turbo.fish site, it was the whimsical coinage of a software developer named Anna Harren, who used it in a Reddit thread. The term caught on and now it's in official documentation and such. Alas, Harren passed away in 2021, but in the Rust source code, in a file named bastion-of-the-turbofish.rs, there remains a memorial to Harren.