Just had a chance to play with @Observable
and I noticed that structs cannot be equatable:
@Observable
struct Foo: Equatable {}
// 🛑 Type 'Foo' does not conform to protocol 'Equatable'
The only reason why it isn't equatable is because ObservationRegistrar
is not. I suppose ObservationRegistrar
could trivially be made equatable by always returning true
from ==
.
Does that seem reasonable to do? And if not, what is the use case of observable structs? It doesn't seem very useful if they can't be made equatable, hashable, codable, etc…. Should @Observable
restrict to only AnyObject
?