From fb1acd933f34c0255f33e05afaaaa60455449bc1 Mon Sep 17 00:00:00 2001 From: Christopher Morton Date: Tue, 30 Nov 2021 15:06:06 +0000 Subject: [PATCH] Add feature: String from EmailAddress Implement the From trait for String. This allows moving the underlying String out of EmailAddress without allocating a new one. Closes #3 --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a858f63..43a8034 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -376,6 +376,12 @@ impl FromStr for EmailAddress { } } +impl From for String { + fn from(email: EmailAddress) -> Self { + email.0 + } +} + impl EmailAddress { /// /// Determine whether the `address` string is a valid email address. Note this is equivalent to