From b865db046216b97d9ddc09ffaa1edb14c13ec17a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 6 May 2020 11:13:00 +0200 Subject: [PATCH] Sort "implementations on foreign types" section in the sidebar --- src/librustdoc/html/render.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 666e59b9a045e..4ad9651d56300 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!("{}", id, Escape(name))) - } - _ => None, - }) - .collect::>(); + .filter_map(|i| extract_for_impl_name(&i.impl_item)) + .collect::>(); + if !res.is_empty() { res.sort(); sidebar.push_str(&format!( "\ Implementations on Foreign Types
{}
", - res.join("") + res.into_iter() + .map(|(name, id)| format!("{}", id, Escape(&name))) + .collect::>() + .join("") )); } }