title: Determine NavigationLink Destination During Initialization
body: <p>I'm trying to determine the destination of a <code>NavigationLink</code> of SwiftUI dynamically within <code>init()</code> based on the generic data provided to the view.</p>
  <p>Based on the code below, if the <code>Item</code> is a <code>Tour</code> the destination should be a <code>TourDetailView</code> and otherwise a <code>LocationDetailView</code>.</p>
  <pre><code>struct CardView&lt;Item: CardItem&gt;: View {
    let card: Item
    private let destination: T
    
    init(card: Item) {
      self.card = card
  
      if Item.self == Tour.self {
        destination = TourDetailView(tour: card as! Tour) as! T
      } else {
        destination = LocationDetailView(location: card as! Location) as! T
      }
    }
    
    var body: some View {
      NavigationLink(destination: destination) {
        ...
      }
    }
  }
  </code></pre>
  <p>Right now the code is not compiling because <code>T</code> isn't defined. If I define <code>T</code> as:</p>
  <p><code>struct CardView&lt;Item: CardItem, T: View&gt;: View {</code></p>
  <p><code>CardView</code> is handled but then I have to edit the View calling the CardView which both introduces unnecessary complexity and eventually I have to define T in <code>@main</code> which is not allowed.</p>
  <p>How can I achieve what I want? I tried to make <code>destination</code> another type but with no success.</p>