netdoc: Improve parsing implementation for RelayFamily.

This commit is contained in:
Nick Mathewson 2020-05-15 14:06:22 -04:00
parent c1d6a74756
commit 84fd65fb85
1 changed files with 5 additions and 5 deletions

View File

@ -97,11 +97,11 @@ pub struct RelayFamily(Vec<RSAIdentity>);
impl std::str::FromStr for RelayFamily {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
let mut family = RelayFamily(Vec::new());
for ent in s.split(crate::tokenize::is_sp) {
family.0.push(parse_family_ent(ent)?);
}
Ok(family)
let v: Result<Vec<RSAIdentity>> = s
.split(crate::tokenize::is_sp)
.map(parse_family_ent)
.collect();
Ok(RelayFamily(v?))
}
}