Type Aliases

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

  1. enum CarryableConcreteItem {
  2.     Left,
  3.     Right,
  4. }
  5. type Item = CarryableConcreteItem;
  6. // Aliases are more useful with long, complex types:
  7. use std::cell::RefCell;
  8. use std::sync::{Arc, RwLock};
  9. type PlayerInventory = RwLock<Vec<Arc<RefCell<Item>>>>;

This slide should take about 2 minutes.

C programmers will recognize this as similar to a typedef.