Skip to content
Typing Summit

Rust typing practice

Type real Rust: enums with match, Option and iterators, structs and impl blocks. Rust uses more symbols than most languages: ::, &, ->, => and closure pipes.

3 snippets · key symbols: :: & -> => | | ! #[ ]

Enum and match · Rust
Press Enter at the end of each line. Indentation is filled in for you.
enum Shape {↵ Circle(f64),↵ Square(f64),↵}↵↵fn area(s: &Shape) -> f64 {↵ match s {↵ Shape::Circle(r) => 3.14159 * r * r,↵ Shape::Square(w) => w * w,↵ }↵}
Guide

How to type Rust faster

Rust has its own set of symbols and patterns. Typing them in real code, with Enter and auto-indent like your editor, builds speed where it matters.

  1. 01

    Paths and references

    The double colon for paths and the ampersand for references appear on nearly every line. They are the two symbols Rust developers type most.
  2. 02

    Match arms and closures

    Match arms use =>, closures use |x|, and return types use ->. Mixing them up is a common typo, so practise them side by side.
  3. 03

    Macros and attributes

    println! and vec! end in an exclamation mark, and attributes like #[derive(Debug)] add the hash and square brackets.

Questions people ask

2 answers

Is Rust hard to type?

+

It is one of the most symbol-heavy languages. Practising ::, &, ->, => and closure pipes in real code makes a big difference.

Does it check my Rust code compiles?

+

No. It checks that you type each character exactly as shown, which is what builds speed and accuracy.