Adopting protocols using a synthesized implementation
Swift can automatically provide protocol conformance for the Equatable, Hashable, and Comparable protocols in specific cases. What this means is that we do not need to write all the boilerplate code to implement these protocols; instead, we can use synthesized implementations provided for us. This only works if the structures or enumerations (not classes) contain only stored properties (for structures) or associated values (for enumerations) that also conform to the Equatable, Hashable, and Comparable protocols.
The Equatable, Hashable, and Comparable protocols are provided within the Swift standard library. Any type that conforms to the Equatable protocols can use the equals operator (==) to compare two instances of the type. Any type that uses the Comparable protocol can use comparative operators to compare two instances of the type. Finally, any type that conforms to the Hashable protocol can be hashed to produce an integer...