api-macro: cleanup: don't use try_fold for a Vec

`collect()` uses `FromIterator` which is also implemented
for `Result<Vec, Err>` from `Result<Item, Err>` doing the
same thing.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-03-06 13:37:59 +01:00
parent 2edd8da965
commit 8e1ace59b1

View File

@ -105,13 +105,10 @@ impl TryFrom<JSONObject> for Schema {
span: obj.brace_token.span, span: obj.brace_token.span,
description, description,
item: SchemaItem::try_extract_from(&mut obj)?, item: SchemaItem::try_extract_from(&mut obj)?,
properties: obj.into_iter().try_fold( properties: obj
Vec::new(), .into_iter()
|mut properties, (key, value)| -> Result<_, syn::Error> { .map(|(key, value)| Ok((key.into_ident(), value.try_into()?)))
properties.push((key.into_ident(), value.try_into()?)); .collect::<Result<_, syn::Error>>()?,
Ok(properties)
},
)?,
}) })
} }
} }