Skip to content

Commit

Permalink
Revert "Added Address:new_unchecked (#887)" (#904)
Browse files Browse the repository at this point in the history
This reverts commit 7e6ffe8.
  • Loading branch information
paolobarbolini authored Sep 1, 2023
1 parent 9476924 commit 4236547
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/address/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,7 @@ impl Address {
pub fn new<U: AsRef<str>, D: AsRef<str>>(user: U, domain: D) -> Result<Self, AddressError> {
(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
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 4236547

Please sign in to comment.