@@ -1837,6 +1837,20 @@ fn get_methods(
18371837 . collect :: < Vec < _ > > ( )
18381838}
18391839
1840+ fn get_associated_constants ( i : & clean:: Impl , used_links : & mut FxHashSet < String > ) -> Vec < String > {
1841+ i. items
1842+ . iter ( )
1843+ . filter_map ( |item| match item. name {
1844+ Some ( ref name) if !name. is_empty ( ) && item. is_associated_const ( ) => Some ( format ! (
1845+ "<a href=\" #{}\" >{}</a>" ,
1846+ get_next_url( used_links, format!( "associatedconstant.{}" , name) ) ,
1847+ name
1848+ ) ) ,
1849+ _ => None ,
1850+ } )
1851+ . collect :: < Vec < _ > > ( )
1852+ }
1853+
18401854// The point is to url encode any potential character from a type with genericity.
18411855fn small_url_encode ( s : String ) -> String {
18421856 let mut st = String :: new ( ) ;
@@ -1881,22 +1895,39 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
18811895
18821896 {
18831897 let used_links_bor = & mut used_links;
1884- let mut ret = v
1898+ let mut assoc_consts = v
1899+ . iter ( )
1900+ . flat_map ( |i| get_associated_constants ( i. inner_impl ( ) , used_links_bor) )
1901+ . collect :: < Vec < _ > > ( ) ;
1902+ if !assoc_consts. is_empty ( ) {
1903+ // We want links' order to be reproducible so we don't use unstable sort.
1904+ assoc_consts. sort ( ) ;
1905+
1906+ out. push_str (
1907+ "<h3 class=\" sidebar-title\" >\
1908+ <a href=\" #implementations\" >Associated Constants</a>\
1909+ </h3>\
1910+ <div class=\" sidebar-links\" >",
1911+ ) ;
1912+ for line in assoc_consts {
1913+ out. push_str ( & line) ;
1914+ }
1915+ out. push_str ( "</div>" ) ;
1916+ }
1917+ let mut methods = v
18851918 . iter ( )
18861919 . filter ( |i| i. inner_impl ( ) . trait_ . is_none ( ) )
1887- . flat_map ( move |i| {
1888- get_methods ( i. inner_impl ( ) , false , used_links_bor, false , cx. tcx ( ) )
1889- } )
1920+ . flat_map ( |i| get_methods ( i. inner_impl ( ) , false , used_links_bor, false , cx. tcx ( ) ) )
18901921 . collect :: < Vec < _ > > ( ) ;
1891- if !ret . is_empty ( ) {
1922+ if !methods . is_empty ( ) {
18921923 // We want links' order to be reproducible so we don't use unstable sort.
1893- ret . sort ( ) ;
1924+ methods . sort ( ) ;
18941925
18951926 out. push_str (
18961927 "<h3 class=\" sidebar-title\" ><a href=\" #implementations\" >Methods</a></h3>\
18971928 <div class=\" sidebar-links\" >",
18981929 ) ;
1899- for line in ret {
1930+ for line in methods {
19001931 out. push_str ( & line) ;
19011932 }
19021933 out. push_str ( "</div>" ) ;
0 commit comments