// *** было: ***
// одно слово для двух разных вещей: настоящего псевдонима и заполнителя,
// который должен заполнить соответствующий тип
protocol ContainerOld {
typealias Item // заполнитель
mutating func append(item: Item)
var count: Int { get }
}
// *** в версии 2.2: ***
protocol Container {
associatedtype Item // явно заполнитель
mutating func append(item: Item)
var count: Int { get }
}
struct IntBag: Container {
typealias Item = Int // а здесь это действительно псевдоним
private var items = [Int]()
mutating func append(item: Int) { items.append(item) }
var count: Int { return items.count }
}