pkstrings: reuse vec we're already consuming in TryFrom<Vec<u8>>
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
fc8786dae9
commit
15d5b09dcb
1 changed files with 7 additions and 1 deletions
|
@ -162,7 +162,13 @@ impl TryFrom<Vec<u8>> for PKString {
|
|||
type Error = Error;
|
||||
|
||||
fn try_from(data: Vec<u8>) -> Result<PKString, Error> {
|
||||
PKString::try_from(data.as_slice())
|
||||
for ord in &data {
|
||||
if ! in_range(*ord) {
|
||||
return Err(Error::InvalidByte(*ord))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(PKString(data))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue