title: What is the correct way to create SwiftUI Binding with array of associative enum?
body: <p>I got some (unexplained) crashes earlier today, and simplified my code to what is seen below. The crashing went away, but I am not 100% sure. Is the code below the correct way to create Binding on an array of enums? And if yes, can this code be made simpler?</p>
  
  <pre><code>import SwiftUI
  
  enum TheEnum: Hashable {
      case one(Int), two(Float)
  }
  
  class TestModel : ObservableObject {
      @Published var enumArray = [TheEnum.one(5), TheEnum.two(6.0)]
  }
  
  struct ContentView: View {
      @ObservedObject var testModel = TestModel()
      var body: some View {
          HStack {
              ForEach(testModel.enumArray, id: \.self) { value -&gt; AnyView in
                  switch value {
                  case .one(var intVal):
                      let b = Binding(get: { 
                          intVal
                      }) {
                          intVal = $0
                      }
                      return AnyView(IntView(intVal: b))
                  case .two(var floatVal):
                      let b = Binding(get: {
                          floatVal
                      }) {
                          floatVal = $0
                      }
                      return AnyView(FloatView(floatVal: b))
                  }
              }
          }
      }
  }
  
  struct IntView: View {
      @Binding var intVal: Int
      var body: some View {
          Text("\(intVal)")
      }
  }
  
  struct FloatView: View {
      @Binding var floatVal: Float
      var body: some View {
          Text("\(floatVal)")
      }
  }
  </code></pre>