title: Can you coerce Some(box|:|) to Option<Box<FnOnce<...>>> in rust?
body: <p>As per the title. Can you? Or does it require an intermediary step for the trait cast?</p>
  
  <p>I realize that the closure reform isn't completely done yet, and there are a number of open bugs with it.</p>
  
  <p>However, the bug tracker is so completely full of bugs and RFCs and links to obsolete and new tickets, I'm having a very hard time trying to understand the state of play with the new unboxed closures in rust.</p>
  
  <p>This works:</p>
  
  <pre><code>#![feature(unboxed_closures, unboxed_closure_sugar)]
  #![allow(dead_code, unused_variables)]
  
  fn test(bar:Box&lt;FnOnce&lt;(int,), ()&gt; + Send&gt;) {
    bar.call_once((10,));
  }
  
  fn main() {
    let bar:Box&lt;FnOnce&lt;(int,), ()&gt; + Send&gt; = box |:x:int| { println!("Hi:{}", x); };
    test(bar);
  
    test(box |:x:int| { println!("Hi:{}", x); });
  }
  </code></pre>
  
  <p>and this works:</p>
  
  <pre><code>#![feature(unboxed_closures, unboxed_closure_sugar)]
  #![allow(dead_code, unused_variables)]
  
  fn test2(mut bar:Option&lt;Box&lt;FnOnce&lt;(int,), ()&gt; + Send&gt;&gt;) {
    bar.take().unwrap().call_once((10,));
  }
  
  fn main() {
    let bar2:Box&lt;FnOnce&lt;(int,), ()&gt; + Send&gt; = box |:x:int| { println!("Hi:{}", x); };
    test2(Some(bar2));
  }
  </code></pre>
  
  <p>However, this doesn't work for some reason:</p>
  
  <pre><code>#![feature(unboxed_closures, unboxed_closure_sugar)]
  #![allow(dead_code, unused_variables)]
  
  fn test2(mut bar:Option&lt;Box&lt;FnOnce&lt;(int,), ()&gt; + Send&gt;&gt;) {
    bar.take().unwrap().call_once((10,));
  }
  
  fn main() {
    test2(Some(box |:x:int| { println!("Hi:{}", x); }));
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>foo.rs:21:9: 21:53 error: mismatched types: expected `core::option::Option&lt;Box&lt;core::ops::FnOnce&lt;(int,), ()&gt;+Send&gt;&gt;`, found `core::option::Option&lt;Box&lt;closure&gt;&gt;` (expected trait core::ops::FnOnce, found closure)
  foo.rs:21   test2(Some(box |:x:int| { println!("Hi:{}", x); }));
  </code></pre>
  
  <p>So, question:</p>
  
  <p>1) <em>Should</em> the above code work? Or does <code>Option&lt;&gt;</code>/<code>Some()</code> imply something complex that I haven't understood in this context?</p>
  
  <p>2) If so, is there an open ticket for implicit conversions between the <code>|:|</code> sugar and <code>FnOnce</code> types?</p>
  
  <p>(because <a href="https://github.com/rust-lang/rust/issues/18101" rel="nofollow">https://github.com/rust-lang/rust/issues/18101</a> seems to suggest it should be done, which is why example #1 works, but I've gotten completely lost trying to hunt through that meta bug to find any specific bug referring to the closure sugar).</p>