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:
parent
93575ab452
commit
1e9da34694
@ -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)?;
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(doc)
|
||||
|
Loading…
Reference in New Issue
Block a user