[Rust] Simple state machine and HashSet (4ms)
\nuse std::collections::HashSet;\n\n#[derive(Debug, Copy, Clone)]\nenum EmailParseState {\n    Name,\n    Plus,\n    Domain\n}\n\nimpl Solution {\n    pub fn nu
```\nuse std::collections::HashSet;\n\n#[derive(Debug, Copy, Clone)]\nenum EmailParseState {\n    Name,\n    Plus,\n    Domain\n}\n\nimpl Solution {\n    pub fn num_unique_emails(emails: Vec<String>) -> i32 {\n        let mut unique_emails = HashSet::new();\n        for email in emails {\n            let nemail = Solution::parse_email(&email);\n            unique_emails.insert(nemail);\n        }\n        unique_emails.len() as i32\n    }\n    \n    fn parse_email(email: &String) -> String {\n        let mut nemail = String::new();\n        let mut state = EmailParseState::Name;\n        \n        for c in email.chars() {\n            let (new_state, ch) = match (state, c) {\n                (EmailParseState::Name, \'.\') => (state, None),\n                (EmailParseState::Name, \'+\') => (EmailParseState::Plus, None),\n                (EmailParseState::Name, \'@\') => (EmailParseState::Domain, Some(c)),\n                (EmailParseState::Name, _) => (state, Some(c)),\n                (EmailParseState::Plus, \'@\') => (EmailParseState::Domain, Some(c)),\n                (EmailParseState::Plus, _) => (state, None),\n                (EmailParseState::Domain, _) => (state, Some(c)),\n            };            \n            if let Some(c) = ch {\n                nemail.push(c);\n            }\n            state = new_state;\n        };\n        nemail\n    }\n}\n```
[]