protocol Animal { mutating func eat() } struct StructCat : Animal { var weight: Int = 1 mutating func eat() { weight += 1 } } func feed(animal: Animal) { var animal = animal animal.eat() dump(animal) } feed(animal: StructCat())
protocol Animal { mutating func eat() mutating func copyFrom(_ other: Self) }