title: Swift: extend a generic type where the associated type is Array
body: <p>I have a type <code>Container&lt;T&gt;</code>. I would like to add an extension where if <code>T</code> is an array, a function can be applied to each element of the array.</p>
  
  <p>Something like:</p>
  
  <pre><code>class Container&lt;T&gt; {
  
      var item: T
  
      init(item: T) {
          self.item = item
      }
  }
  
  extension Container where T: Array&lt;Element&gt; {
  
      func mapElements&lt;U&gt;(transform: (Element) -&gt; U ) -&gt; Container&lt;[U]&gt; {
          return Container(item.map(transform))
      }
  }
  </code></pre>
  
  <p>The above code does not compile of course: <code>! Use of undeclared type Element</code> </p>
  
  <p>Any ideas on if/how this might be accomplished?</p>