title: The trait `std::ops::Fn<(char,)>` is not implemented for `T`
body: <p>I am trying to implement the greps project and I am stuck at the search function.</p>
  
  <pre><code>fn search&lt;'a, T&gt;(query: &amp;T, contents: &amp;'a str) -&gt; Vec&lt;&amp;'a str&gt; {
      let mut results = Vec::new();
  
      for line in contents.lines() {
          if line.contains(query) {
              results.push(line);
          }
      }
      results
  }
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>rustc 1.18.0 (03fc9d622 2017-06-06)
  error[E0277]: the trait bound `T: std::ops::Fn&lt;(char,)&gt;` is not satisfied
    --&gt; &lt;anon&gt;:39:17
     |
  39 |         if line.contains(query) {
     |                 ^^^^^^^^ the trait `std::ops::Fn&lt;(char,)&gt;` is not implemented for `T`
     |
     = help: consider adding a `where T: std::ops::Fn&lt;(char,)&gt;` bound
     = note: required because of the requirements on the impl of `std::ops::FnOnce&lt;(char,)&gt;` for `&amp;T`
     = note: required because of the requirements on the impl of `std::str::pattern::Pattern&lt;'_&gt;` for `&amp;T`
  
  error[E0277]: the trait bound `T: std::ops::FnOnce&lt;(char,)&gt;` is not satisfied
    --&gt; &lt;anon&gt;:39:17
     |
  39 |         if line.contains(query) {
     |                 ^^^^^^^^ the trait `std::ops::FnOnce&lt;(char,)&gt;` is not implemented for `T`
     |
     = help: consider adding a `where T: std::ops::FnOnce&lt;(char,)&gt;` bound
     = note: required because of the requirements on the impl of `std::str::pattern::Pattern&lt;'_&gt;` for `&amp;T`
  
  error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied
    --&gt; &lt;anon&gt;:57:40
     |
  57 |         assert_eq!(vec!["KAMEHAMEHA"], search(query, contents));
     |                                        ^^^^^^ the trait `std::marker::Sized` is not implemented for `str`
     |
     = note: `str` does not have a constant size known at compile-time
     = note: required by `search`
  </code></pre>
  
  <p>Why do I need the <code>Fn</code> trait? Adding that trait isn't solving my problem. I am using generics, and I know I don't really need generics here but I am trying to understand the topic. </p>
  
  <p>Here is the full code on Rust <a href="https://play.rust-lang.org/?gist=ca11eb8e51982f63a61ff05c542ec0db&amp;version=stable&amp;backtrace=0" rel="nofollow noreferrer">playground</a>.</p>