MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from

Method from

atomic-core/src/change/header.rs:146–168  ·  view source on GitHub ↗

Parse an author from a string like "Name \ ". If no email is found, the entire string is used as the name.

(s: &str)

Source from the content-addressed store, hash-verified

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
171impl From<String> for Author {

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected