title: Swift Generics: where in type declaration
body: <p>I'm trying to make an API that allows a caller to pass a subclass of <code>UIView</code> and a block to a function, and later the receiver will call that block with the given <code>UIView</code> subclass instance and another argument. I've broken down the issue so that it runs in a playground:</p>
  
  <pre><code>import UIKit
  
  struct SomeStruct&lt;T where T: UIView&gt; {
  
      let view: T
      let block: ((T, Int) -&gt; Void)
  
      //some computed variables here that rely on T being a UIView
  }
  
  class SomeClass {
  
      var data: SomeStruct&lt;UIView&gt;? //Ideally, SomeStruct&lt;? where ? : UIView&gt;
  
      func doSomethingLater&lt;V where V: UIView&gt;(view: V, block: ((V, Int) -&gt; Void)) {
  
          //Cannot convert value of type '(V, Int) -&gt; Void' to expected argument type '(_, Int) -&gt; Void'
          self.data = SomeStruct(view: view, block: block)
      }
  }
  </code></pre>
  
  <p><br>
  The caller would then use <code>SomeClass</code> like this:</p>
  
  <pre><code>let c = SomeClass()
  
  let label = UILabel()
  c.doSomethingLater(b) { (label, idx) in
      //l is type UILabel
  }   
  
  let button = UIButton(type: .Custom)
  c.doSomethingLater(b) { (button, idx) in
      //b is type UIButton
  } 
  </code></pre>
  
  <p>My reasoning behind wanting to restrict to subclasses of <code>UIView</code> rather than a <code>UIView</code> itself is so that from within the block, the caller does not need to cast the argument to it's original type</p>
  
  <p>So, my question is: is there a way to use the <code>where</code> clause when declaring a variable's type? </p>