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:
Maxime “pep” Buquet 2021-11-15 18:47:15 +01:00
parent fc8786dae9
commit 15d5b09dcb
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -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))
}
}