From 42365478c2731e33759eeccc531fda34e6514fa2 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Fri, 1 Sep 2023 16:06:48 +0200 Subject: [PATCH] Revert "Added Address:new_unchecked (#887)" (#904) This reverts commit 7e6ffe8aea301eef2125415e80297bdf6cf6c0e8. --- src/address/types.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/address/types.rs b/src/address/types.rs index b02f580..f18c84e 100644 --- a/src/address/types.rs +++ b/src/address/types.rs @@ -73,18 +73,7 @@ impl Address { pub fn new, D: AsRef>(user: U, domain: D) -> Result { (user, domain).try_into() } - /// Creates a new email address from a string without checking it. - /// - /// # Panics - /// Will panic if @ is not present in the string - pub fn new_unchecked(serialized: String) -> Self { - let at_start = serialized.chars().position(|c| c == '@').unwrap(); - Self { - serialized, - at_start, - } - } /// Gets the user portion of the `Address`. /// /// # Examples @@ -314,19 +303,4 @@ mod tests { Address::check_domain("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com").is_err() ); } - - #[test] - fn test_new_unchecked() { - let addr = Address::new_unchecked("something@example.com".to_owned()); - assert_eq!(addr.user(), "something"); - assert_eq!(addr.domain(), "example.com"); - - assert_eq!(addr, Address::new("something", "example.com").unwrap()); - } - - #[test] - #[should_panic] - fn test_new_unchecked_panic() { - Address::new_unchecked("somethingexample.com".to_owned()); - } }