title: Converting an Option<impl Trait> to an Option<Box<dyn Trait>>
body: <p>Is it possible to map an <code>Option&lt;impl Trait&gt;</code> to a <code>Option&lt;Box&lt;dyn Trait&gt;&gt;</code>? If the argument to <code>new()</code> is not an <code>Option</code>, it is possible to assign it to a <code>struct</code> with <code>Some(Box::new(item))</code>. Why does this work and the map doesn't?</p>
  <pre><code>trait TestTrait {}
  
  impl TestTrait for i32 {}
  
  struct TestStruct {
      item: Option&lt;Box&lt;dyn TestTrait&gt;&gt;
  }
  
  impl TestStruct {
      pub fn new(item: Option&lt;impl TestTrait + 'static&gt;) -&gt; Self {
          let item: Option&lt;Box&lt;dyn TestTrait&gt;&gt; = item.map(|i| Box::new(i));
          Self {
              item
          }
      }
  }
  
  
  fn main() {    
      let num:i32 = 0;
      let s = TestStruct::new(Some(num));
  }
  </code></pre>