I have this which is really pleasant to the eye, but I'm concerned about its implications:
#[derive(Eq, PartialEq, Debug)]
pub enum SmtpHost {
DOMAIN(String),
IPV4(Ipv4Addr),
IPV6(Ipv6Addr),
UNKNOWN { label:String, literal:String },
}
I'm filling this up from a PEG grammar which gives me &str so all the stringy calls look like this - SmtpHost::Domain(s.to_string())
I would like these enums to be the outcome of the parser, like smtp_parser::host< 'input >(s: 'input & str) -> SmtpHost
I have also tried the ref approach, but that starts getting clumsy rather soon:
#[derive(Eq, PartialEq, Debug)]
pub enum SmtpHost<'a > {
DOMAIN(&'a str),
IPV4(Ipv4Addr),
IPV6(Ipv6Addr),
UNKNOWN { label:&'a str, literal:&'a str },
}
So I'm like either / or ... but you know better. Tell me :o)