title: How do I clone a closure, so that their types are the same?
body: <p>I have a struct which looks something like this:</p>
  
  <pre><code>pub struct MyStruct&lt;F&gt;
  where
      F: Fn(usize) -&gt; f64,
  {
      field: usize,
      mapper: F,
      // fields omitted
  }
  </code></pre>
  
  <p>How do I implement <code>Clone</code> for this struct?</p>
  
  <p>One way I found to copy the function body is:</p>
  
  <pre><code>let mapper = |x| (mystruct.mapper)(x);
  </code></pre>
  
  <p>But this results in <code>mapper</code> having a different type than that of <code>mystruct.mapper</code>.</p>
  
  <p><a href="https://play.rust-lang.org/?gist=fdf8bec546f6e13f4e517d07e86d423b&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">playground</a></p>