title: Implement trait for closure type alias
body: <p>I have this closure type alias:</p>
  
  <pre><code>type ClosureType = Box&lt;Fn(i32) -&gt; i32&gt;;
  </code></pre>
  
  <p>this trait:</p>
  
  <pre><code>trait Trait {
      fn change(&amp;self, y: i32) -&gt; i32;
  }
  </code></pre>
  
  <p>and these functions:</p>
  
  <pre><code>fn with_one(x: Box&lt;Fn(i32) -&gt; i32&gt;) -&gt; i32 {
      x(1)
  }
  
  fn plus_one(x: i32) -&gt; i32 {
      x+1
  }
  
  fn main() {
      let a = Box::new(|x: i32|{x+1});
      let b: ClosureType = Box::new(|x: i32|{x+1});
      let c = Box::new(plus_one);
      let d: ClosureType = Box::new(plus_one);
      println!("{}", a.change(1));
      println!("{}", b.change(1));
      println!("{}", c.change(1));
      println!("{}", d.change(1));
      println!("{}", with_one(a));
      println!("{}", with_one(b));
      println!("{}", with_one(c));
      println!("{}", with_one(d));
  }
  </code></pre>
  
  <p>When I implement the trait <code>Trait</code> for <code>ClosureType</code> or for <code>Box&lt;Fn(i32) -&gt; i32&gt;</code> which is the same if I understand correctly type aliases:</p>
  
  <pre><code>impl Trait for ClosureType {
      fn change(&amp;self, y: i32) -&gt; i32{
          self(y)
      }
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>impl Trait for Box&lt;Fn(i32) -&gt; i32&gt; {
      fn change(&amp;self, y: i32) -&gt; i32{
          self(y)
      }
  }
  </code></pre>
  
  <p>for variable <code>a</code> I get:</p>
  
  <pre><code>&lt;anon&gt;:32:22: 32:31 error: no method named `change` found for type
  `Box&lt;[closure &lt;anon&gt;:28:22: 28:35]&gt;` in the current scope 
  &lt;anon&gt;:32     println!("{}", a.change(1));
  </code></pre>
  
  <p>and for variable <code>c</code>  I get:</p>
  
  <pre><code>&lt;anon&gt;:34:22: 34:31 error: no method named `change` found for type
  `Box&lt;fn(i32) -&gt; i32 {plus_one}&gt;` in the current scope
  &lt;anon&gt;:34     println!("{}", c.change(1));
  </code></pre>
  
  <p>However variables <code>a</code> and <code>c</code> are accepted from function <code>with_one(x: Box&lt;Fn(i32) -&gt; i32&gt;) -&gt; i32</code>, in other words it seems that they have the same type(<code>Box&lt;Fn(i32) -&gt; i32&gt;</code>) for function <code>with_one</code> but different(<code>Box&lt;[closure &lt;anon&gt;:24:22: 24:35]&gt;</code> and <code>Box&lt;fn(i32) -&gt; i32 {plus_one}</code>) for <code>Trait</code> implementation.</p>
  
  <p>I feel I missing something here but not sure what it is, could you enlighten me?</p>
  
  <p>you can find all the code in <a href="https://play.rust-lang.org/?gist=9bfcd27580cf078e0551" rel="nofollow">this rust playground</a>.</p>