I have the following enum with an equatable conformance
enum SpeechRecognizerState {
case ready
case permissionDenied
case listening
case stopped
case error(error:Error)
}
extension SpeechRecognizerState: Equatable {
static func ==(lhs: SpeechRecognizerState, rhs: SpeechRecognizerState) -> Bool {
switch (lhs, rhs) {
case (.ready, .ready),
(.permissionDenied, .permissionDenied),
(.listening, .listening),
(.stopped, .stopped),
(.error, .error):
return true
default:
return false
}
}
}
That feels like a lot of boilerplate in the equatable to write
static func ==(lhs: SpeechRecognizerState, rhs: SpeechRecognizerState) -> Bool {
return lhs.caseElement == rhs.caseElement
}