title: Why is the trait bound Trait<&String> not satisfied even though I've implemented Trait<&str>?
body: <p>I have written the following code:</p>
  
  <pre><code>pub struct Serializer;
  
  pub trait Serialize&lt;T&gt; {
      fn to_bert(&amp;self, data: T) -&gt; Vec&lt;u8&gt;;
  }
  
  pub trait Convert&lt;T&gt; {
      fn to_binary(&amp;self, data: T) -&gt; Vec&lt;u8&gt;;
  }
  
  impl&lt;'a&gt; Convert&lt;&amp;'a str&gt; for Serializer {
      fn to_binary(&amp;self, data: &amp;'a str) -&gt; Vec&lt;u8&gt; {
          let binary_string = data.as_bytes();
          let binary_length = binary_string.len() as i16;
          let mut binary = vec![];
          binary.write_i16::&lt;BigEndian&gt;(binary_length).unwrap();
          binary.extend(binary_string.iter().clone());
          binary
      }
  }
  
  impl Serialize&lt;String&gt; for Serializer {
      fn to_bert(&amp;self, data: String) -&gt; Vec&lt;u8&gt; {
          let binary_string = self.to_binary(&amp;data);
          self.generate_term(BertTag::String, binary_string)
      }
  }
  
  impl&lt;'a&gt; Serialize&lt;&amp;'a str&gt; for Serializer {
      fn to_bert(&amp;self, data: &amp;'a str) -&gt; Vec&lt;u8&gt; {
          let binary_string = self.to_binary(data);
          self.generate_term(BertTag::String, binary_string)
      }
  }
  </code></pre>
  
  <p>When compiling, I receive an error which says the compiler cannot find the right function for a call:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: the trait bound `serializers::Serializer: serializers::Convert&lt;&amp;std::string::String&gt;` is not satisfied [E0277]
  let binary_string = self.to_binary(&amp;data);
                           ^~~~~~~~~
  help: run `rustc --explain E0277` to see a detailed explanation
  help: the following implementations were found:
  help:   &lt;serializers::Serializer as serializers::Convert&lt;&amp;'a str&gt;&gt;
  help:   &lt;serializers::Serializer as serializers::Convert&lt;types::BertType&gt;&gt;
  </code></pre>
  
  <p>Why can the compiler not find the right implementation when I've specified <code>&amp;str</code> with a lifetime? How can I fix this?</p>