Parse an author from a string like "Name \ ". If no email is found, the entire string is used as the name.
(s: &str)
| 144 | /// |
| 145 | /// If no email is found, the entire string is used as the name. |
| 146 | fn from(s: &str) -> Self { |
| 147 | // Try to parse "Name <email>" format |
| 148 | if let Some(start) = s.find('<') { |
| 149 | if let Some(end) = s.find('>') { |
| 150 | if start < end { |
| 151 | let name = s[..start].trim().to_string(); |
| 152 | let email = s[start + 1..end].trim().to_string(); |
| 153 | return Self { |
| 154 | name, |
| 155 | email: Some(email), |
| 156 | identity: None, |
| 157 | }; |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // No email found, use entire string as name |
| 163 | Self { |
| 164 | name: s.trim().to_string(), |
| 165 | email: None, |
| 166 | identity: None, |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | impl From<String> for Author { |