title: Simplify function declaration
body: <p>I would like to simplify the declaration of the following function:</p>
  
  <pre class="lang-rust prettyprint-override"><code>use regex::Regex;
  
  fn oper&lt;'a, F&gt;(regex: &amp;str, op: F) -&gt; (Regex, Box&lt;dyn Fn(i32, i32) -&gt; i32 + 'a&gt;)
  where F: Fn(i32, i32) -&gt; i32 + 'a
  {
      (Regex::new(regex).unwrap(), Box::new(op))
  }
  </code></pre>
  
  <p>I tried to replace the <code>Fn</code> trait by <code>F</code> in the return value, but it raises an error:</p>
  
  <pre class="lang-rust prettyprint-override"><code>fn oper&lt;'a, F&gt;(regex: &amp;str, op: F) -&gt; (Regex, Box&lt;dyn F&gt;)
  where F: Fn(i32, i32) -&gt; i32 + 'a
  {
      (Regex::new(regex).unwrap(), Box::new(op))
  }
  </code></pre>
  
  <pre><code>error[E0404]: expected trait, found type parameter `F`
    --&gt; src/lib.rs:5:55
     |
  5  |   fn oper&lt;'a, F&gt;(regex: &amp;str, op: F) -&gt; (Regex, Box&lt;dyn F&gt;)
     |                                                         ^ help: a trait with a similar name exists: `Fn`
  
  error: aborting due to previous error
  </code></pre>
  
  <p>How can simplify this declaration to avoid duplication of <code>Fn(i32, i32) -&gt; i32 + 'a</code>?</p>