Rollup merge of #71945 - GuillaumeGomez:sort-impl-on-foreign-types-section, r=kinnison,ollie27

Sort "implementations on foreign types" section in the sidebar

Fixes #71926.

We were sorting by the ID instead of sorting by the name. They're not in the same order as the implementations but I think it makes more sense this way considering this is what we do for the methods as well.

r? @kinnison

cc @rust-lang/rustdoc
This commit is contained in:
Ralf Jung 2020-05-10 11:34:34 +02:00 committed by GitHub
commit d22c18b396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4344,20 +4344,19 @@ fn sidebar_trait(buf: &mut Buffer, it: &clean::Item, t: &clean::Trait) {
let mut res = implementors
.iter()
.filter(|i| i.inner_impl().for_.def_id().map_or(false, |d| !c.paths.contains_key(&d)))
.filter_map(|i| match extract_for_impl_name(&i.impl_item) {
Some((ref name, ref id)) => {
Some(format!("<a href=\"#{}\">{}</a>", id, Escape(name)))
}
_ => None,
})
.collect::<Vec<String>>();
.filter_map(|i| extract_for_impl_name(&i.impl_item))
.collect::<Vec<_>>();
if !res.is_empty() {
res.sort();
sidebar.push_str(&format!(
"<a class=\"sidebar-title\" href=\"#foreign-impls\">\
Implementations on Foreign Types</a><div \
class=\"sidebar-links\">{}</div>",
res.join("")
res.into_iter()
.map(|(name, id)| format!("<a href=\"#{}\">{}</a>", id, Escape(&name)))
.collect::<Vec<_>>()
.join("")
));
}
}