title: Is it possible to use a generic inside a generic struct init in Swift?
body: <p>I would like to know if it is possible to use a generic type to initialize another generic. I put a example code below.</p>
  
  <pre><code>struct Object: Decodable {
      let id: String?
      let type: String?
  }
  
  struct JSON&lt;T: Decodable&gt;: Decodable {
      let data: T?
  }
  
  func test&lt;T: Decodable&gt;(type: T.Type) {
      let dataFromAPI = Data()
      let model = JSONDecoder().decode(JSON&lt;type&gt;, from: dataFromAPI)
  }
  </code></pre>
  
  <p>I am receiving this error message:</p>
  
  <blockquote>
    <p>Use of undeclared type 'type'</p>
  </blockquote>