Sort implementations alphabetically

For consistency and easier testing, we sort the implementation items
alphabetically by their name and their definitions.
This commit is contained in:
Robin Krahl 2020-07-26 14:31:51 +02:00
parent ae0a741d5a
commit 3c06846a30
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8
2 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,7 @@ SPDX-License-Identifier: MIT
- Show the definition for constants and typedefs. - Show the definition for constants and typedefs.
- Fix group and ID for typdef items. - Fix group and ID for typdef items.
- Extract the description of module items as HTML instead of plain text. - Extract the description of module items as HTML instead of plain text.
- Sort implementations alphabetically.
## v0.1.2 (2020-07-25) ## v0.1.2 (2020-07-25)

View File

@ -484,6 +484,8 @@ fn get_implementation_group(
} }
} }
impls.sort();
Ok(impls.into_member_group(Some(title.to_owned()))) Ok(impls.into_member_group(Some(title.to_owned())))
} }
@ -578,6 +580,14 @@ impl<'a> MemberDocs<'a> {
} }
} }
pub fn sort(&mut self) {
self.docs.sort_by(|d1, d2| {
d1.name
.cmp(&d2.name)
.then_with(|| d1.definition.cmp(&d2.definition))
})
}
pub fn push( pub fn push(
&mut self, &mut self,
name: &mut Option<String>, name: &mut Option<String>,