title: What's the best practice for str/String values in Rust enums?
body: <p>I have this which is really pleasant to the eye, but I'm concerned about its implications:</p>
  
  <pre><code>#[derive(Eq, PartialEq, Debug)]
  pub enum SmtpHost {     
      DOMAIN(String),
      IPV4(Ipv4Addr),
      IPV6(Ipv6Addr),
      UNKNOWN { label:String, literal:String },
  }
  </code></pre>
  
  <p>I'm filling this up from a PEG grammar which gives me <code>&amp;str</code> so all the stringy calls look like this - <code>SmtpHost::Domain(s.to_string())</code></p>
  
  <p>I would like these enums to be the outcome of the parser, like <code>smtp_parser::host&lt; 'input &gt;(s: 'input &amp; str) -&gt; SmtpHost</code></p>
  
  <p>I have also tried the ref approach, but that starts getting clumsy rather soon:</p>
  
  <pre><code>#[derive(Eq, PartialEq, Debug)]
  pub enum SmtpHost&lt;'a &gt; {     
      DOMAIN(&amp;'a str),
      IPV4(Ipv4Addr),
      IPV6(Ipv6Addr),
      UNKNOWN { label:&amp;'a str, literal:&amp;'a str },
  }
  </code></pre>
  
  <p>So I'm like either / or ... but you know better. Tell me :o)</p>
  
  <p>My <a href="https://github.com/jocutajar/ResistRustNot.SmtpServer/blob/develop/src/smtp.rustpeg" rel="nofollow noreferrer">study project for reference</a></p>