@@ -1837,6 +1837,20 @@ fn get_methods(
1837
1837
. collect :: < Vec < _ > > ( )
1838
1838
}
1839
1839
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
+
1840
1854
// The point is to url encode any potential character from a type with genericity.
1841
1855
fn small_url_encode ( s : String ) -> String {
1842
1856
let mut st = String :: new ( ) ;
@@ -1881,22 +1895,39 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
1881
1895
1882
1896
{
1883
1897
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
1885
1918
. iter ( )
1886
1919
. 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 ( ) ) )
1890
1921
. collect :: < Vec < _ > > ( ) ;
1891
- if !ret . is_empty ( ) {
1922
+ if !methods . is_empty ( ) {
1892
1923
// We want links' order to be reproducible so we don't use unstable sort.
1893
- ret . sort ( ) ;
1924
+ methods . sort ( ) ;
1894
1925
1895
1926
out. push_str (
1896
1927
"<h3 class=\" sidebar-title\" ><a href=\" #implementations\" >Methods</a></h3>\
1897
1928
<div class=\" sidebar-links\" >",
1898
1929
) ;
1899
- for line in ret {
1930
+ for line in methods {
1900
1931
out. push_str ( & line) ;
1901
1932
}
1902
1933
out. push_str ( "</div>" ) ;
0 commit comments