From 19853cec292aeab701ea49ed1ca8a19050487ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 30 Jun 2020 00:54:18 +0200 Subject: [PATCH] pkstrings: implement TryFrom<&str> via TryFrom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- pkstrings/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pkstrings/src/lib.rs b/pkstrings/src/lib.rs index e710771..52754e8 100644 --- a/pkstrings/src/lib.rs +++ b/pkstrings/src/lib.rs @@ -147,13 +147,7 @@ impl TryFrom<&str> for PKString { type Error = Error; fn try_from(data: &str) -> Result { - for chr in data.chars() { - if ! STRTOHEX.contains_key(&chr) { - return Err(Error::InvalidCharacter); - } - } - - Ok(PKString(String::from(data))) + PKString::try_from(String::from(data)) } }