型エイリアス
型エイリアスは、別の型の名前を作成します。この 2 つの型は同じ意味で使用できます。
enum CarryableConcreteItem {
Left,
Right,
}
type Item = CarryableConcreteItem;
// エイリアスは長くて複雑な型に使用すると便利です。
use std::cell::RefCell;
use std::sync::{Arc, RwLock};
type PlayerInventory = RwLock<Vec<Arc<RefCell<Item>>>>;
This slide should take about 2 minutes.
C プログラマーは、これを typedef と同様のものと考えるでしょう。