diff options
| author | Ralf Jung <post@ralfj.de> | 2020-05-10 11:34:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-10 11:34:34 +0200 |
| commit | d22c18b3965ad9f0b291f3a5a0fd2b706717f337 (patch) | |
| tree | 3294c708b9d7b5d78e4f7b8c1aae12e47e45f875 | |
| parent | 37a91928268a36f1f071edb97b944063d8370422 (diff) | |
| parent | b865db046216b97d9ddc09ffaa1edb14c13ec17a (diff) | |
| download | rust-d22c18b3965ad9f0b291f3a5a0fd2b706717f337.tar.gz rust-d22c18b3965ad9f0b291f3a5a0fd2b706717f337.zip | |
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
| -rw-r--r-- | src/librustdoc/html/render.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 666e59b9a04..4ad9651d563 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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("") )); } } |
