title: How do I implement Into<MyType> for &str
body: <p>I have a custom type <code>pub struct Foo</code> and I'd like to be able to say strings can be converted to <code>Foo</code> types. I'm trying to do <code>impl&lt;'a&gt; Into&lt;Foo&gt; for &amp;'a str</code>, but I know from <a href="https://stackoverflow.com/questions/24594374/overload-operators-with-different-rhs-type/24594911#24594911">this answer</a> that I can't do that. What other options do I have?</p>
  
  <p>For context, I'm trying to do something like</p>
  
  <pre><code>trait Foo {
      type ArgType;
      fn new&lt;I: Into&lt;Self::ArgType&gt;&gt;(arg: I) -&gt; Self;
  }
  
  struct MyType;
  impl Into&lt;MyType&gt; for str {
      fn into(self) -&gt; MyType { MyType }
  }
  
  struct Bar;
  impl Foo for Bar {
      type ArgType = MyType;
      fn new&lt;I: Into&lt;MyType&gt;&gt;(arg: I) -&gt; Bar { Bar }
  }
  </code></pre>