Function email_address_list::parse_contact
source · Expand description
Parse only a single Contact
, ignore the rest
Just like parse_address_list
, this function “fails” with
Error::Empty
when the supplied string is empty.
Examples
Single contact:
let single = parse_contact("<retpoŝto+kontakto@example.org>").unwrap();
assert!(single.deep_eq(&Contact::new("retpoŝto+kontakto@example.org")));
Multiple contacts:
let multiple = parse_contact("courriel@example.org, exemple@example.org").unwrap();
assert!(multiple.deep_eq(&Contact::new("courriel@example.org")));
Not a contact:
match parse_contact("Mist").unwrap() {
Contact::Garbage(_) => assert!(true),
Contact::Email(_) => assert!(false),
}
Empty input:
match parse_contact(",") {
Err(error::Error::Empty) => assert!(true),
Ok(_) | Err(_) => assert!(false),
}