pkstrings: implement TryFrom<&str> via TryFrom<String>
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
0ecc19a2fc
commit
19853cec29
1 changed files with 1 additions and 7 deletions
|
@ -147,13 +147,7 @@ impl TryFrom<&str> for PKString {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from(data: &str) -> Result<PKString, Error> {
|
fn try_from(data: &str) -> Result<PKString, Error> {
|
||||||
for chr in data.chars() {
|
PKString::try_from(String::from(data))
|
||||||
if ! STRTOHEX.contains_key(&chr) {
|
|
||||||
return Err(Error::InvalidCharacter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(PKString(String::from(data)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue