In theory, it sounds nice—this can be handy when you know you won't be dealing with any duplicates. In actuality, enumerations (and other Hashable
types) are unsuitable for the semantics of Identifiable
, in the general case. This should be better documented.
E.g. try interacting with this nightmare:
import SwiftUI
struct UnusableView: View {
enum Case: Identifiable {
case a, b
var id: some Hashable { self }
}
@State var cases: [Case] = [.a, .b, .a, .b]
var body: some View {
List($cases, editActions: .move) { $case in
Text("\(`case`)" as String)
}
}
}
#Preview(body: UnusableView.init)