Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Type Aliases

A type alias creates a name for another type. The two types can be used interchangeably.

enum CarryableConcreteItem {
    Left,
    Right,
}

type Item = CarryableConcreteItem;

// Aliases are more useful with long, complex types:
use std::sync::Mutex;
type PlayerInventory = Mutex<Vec<Item>>;
This slide should take about 2 minutes.

C programmers will recognize this as similar to a typedef.