Refactor Parser::parse_item_doc

This patch simplifies the Parser::parse_item_doc function by collecting
all members before pushing them into the member groups.
This commit is contained in:
Robin Krahl 2020-08-17 10:44:49 +02:00
parent 93575ab452
commit 1e9da34694
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8

View File

@ -77,25 +77,17 @@ impl Parser {
doc.description = description.map(From::from);
doc.definition = definition.map(From::from);
let (ty, groups) = get_variants(&self.document, name)?;
let members = vec![
get_variants(&self.document, name)?,
get_fields(&self.document, name)?,
get_assoc_types(&self.document, name)?,
get_methods(&self.document, name)?,
get_implementations(&self.document, name)?,
];
for (ty, groups) in members.into_iter() {
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
let (ty, groups) = get_fields(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
let (ty, groups) = get_assoc_types(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
let (ty, groups) = get_methods(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
let (ty, groups) = get_implementations(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
Ok(doc)