@@ -3016,6 +3016,22 @@ fn item_trait(
30163016 // Trait documentation
30173017 document ( w, cx, it) ?;
30183018
3019+ fn write_small_section_header (
3020+ w : & mut fmt:: Formatter ,
3021+ id : & str ,
3022+ title : & str ,
3023+ extra_content : & str ,
3024+ ) -> fmt:: Result {
3025+ write ! ( w, "
3026+ <h2 id='{0}' class='small-section-header'>\
3027+ {1}<a href='#{0}' class='anchor'></a>\
3028+ </h2>{2}", id, title, extra_content)
3029+ }
3030+
3031+ fn write_loading_content ( w : & mut fmt:: Formatter , extra_content : & str ) -> fmt:: Result {
3032+ write ! ( w, "{}<span class='loading-content'>Loading content...</span>" , extra_content)
3033+ }
3034+
30193035 fn trait_item ( w : & mut fmt:: Formatter , cx : & Context , m : & clean:: Item , t : & clean:: Item )
30203036 -> fmt:: Result {
30213037 let name = m. name . as_ref ( ) . unwrap ( ) ;
@@ -3036,74 +3052,45 @@ fn item_trait(
30363052 }
30373053
30383054 if !types. is_empty ( ) {
3039- write ! ( w, "
3040- <h2 id='associated-types' class='small-section-header'>
3041- Associated Types<a href='#associated-types' class='anchor'></a>
3042- </h2>
3043- <div class='methods'>
3044- " ) ?;
3055+ write_small_section_header ( w, "associated-types" , "Associated Types" ,
3056+ "<div class='methods'>" ) ?;
30453057 for t in & types {
30463058 trait_item ( w, cx, * t, it) ?;
30473059 }
3048- write ! ( w, "</div>" ) ?;
3060+ write_loading_content ( w, "</div>" ) ?;
30493061 }
30503062
30513063 if !consts. is_empty ( ) {
3052- write ! ( w, "
3053- <h2 id='associated-const' class='small-section-header'>
3054- Associated Constants<a href='#associated-const' class='anchor'></a>
3055- </h2>
3056- <div class='methods'>
3057- " ) ?;
3064+ write_small_section_header ( w, "associated-const" , "Associated Constants" ,
3065+ "<div class='methods'>" ) ?;
30583066 for t in & consts {
30593067 trait_item ( w, cx, * t, it) ?;
30603068 }
3061- write ! ( w, "</div>" ) ?;
3069+ write_loading_content ( w, "</div>" ) ?;
30623070 }
30633071
30643072 // Output the documentation for each function individually
30653073 if !required. is_empty ( ) {
3066- write ! ( w, "
3067- <h2 id='required-methods' class='small-section-header'>
3068- Required Methods<a href='#required-methods' class='anchor'></a>
3069- </h2>
3070- <div class='methods'>
3071- " ) ?;
3074+ write_small_section_header ( w, "required-methods" , "Required methods" ,
3075+ "<div class='methods'>" ) ?;
30723076 for m in & required {
30733077 trait_item ( w, cx, * m, it) ?;
30743078 }
3075- write ! ( w, "</div>" ) ?;
3079+ write_loading_content ( w, "</div>" ) ?;
30763080 }
30773081 if !provided. is_empty ( ) {
3078- write ! ( w, "
3079- <h2 id='provided-methods' class='small-section-header'>
3080- Provided Methods<a href='#provided-methods' class='anchor'></a>
3081- </h2>
3082- <div class='methods'>
3083- " ) ?;
3082+ write_small_section_header ( w, "provided-methods" , "Provided methods" ,
3083+ "<div class='methods'>" ) ?;
30843084 for m in & provided {
30853085 trait_item ( w, cx, * m, it) ?;
30863086 }
3087- write ! ( w, "</div>" ) ?;
3087+ write_loading_content ( w, "</div>" ) ?;
30883088 }
30893089
30903090 // If there are methods directly on this trait object, render them here.
30913091 render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All ) ?;
30923092
30933093 let cache = cache ( ) ;
3094- let impl_header = "\
3095- <h2 id='implementors' class='small-section-header'>\
3096- Implementors<a href='#implementors' class='anchor'></a>\
3097- </h2>\
3098- <div class='item-list' id='implementors-list'>\
3099- ";
3100-
3101- let synthetic_impl_header = "\
3102- <h2 id='synthetic-implementors' class='small-section-header'>\
3103- Auto implementors<a href='#synthetic-implementors' class='anchor'></a>\
3104- </h2>\
3105- <div class='item-list' id='synthetic-implementors-list'>\
3106- ";
31073094
31083095 let mut synthetic_types = Vec :: new ( ) ;
31093096
@@ -3140,11 +3127,7 @@ fn item_trait(
31403127 concrete. sort_by ( compare_impl) ;
31413128
31423129 if !foreign. is_empty ( ) {
3143- write ! ( w, "
3144- <h2 id='foreign-impls' class='small-section-header'>
3145- Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a>
3146- </h2>
3147- " ) ?;
3130+ write_small_section_header ( w, "foreign-impls" , "Implementations on Foreign Types" , "" ) ?;
31483131
31493132 for implementor in foreign {
31503133 let assoc_link = AssocItemLink :: GotoSource (
@@ -3155,33 +3138,38 @@ fn item_trait(
31553138 RenderMode :: Normal , implementor. impl_item . stable_since ( ) , false ,
31563139 None ) ?;
31573140 }
3141+ write_loading_content ( w, "" ) ?;
31583142 }
31593143
3160- write ! ( w, "{}" , impl_header) ?;
3144+ write_small_section_header ( w, "implementors" , "Implementors" ,
3145+ "<div class='item-list' id='implementors-list'>" ) ?;
31613146 for implementor in concrete {
31623147 render_implementor ( cx, implementor, w, & implementor_dups) ?;
31633148 }
3164- write ! ( w, "</div>" ) ?;
3149+ write_loading_content ( w, "</div>" ) ?;
31653150
31663151 if t. auto {
3167- write ! ( w, "{}" , synthetic_impl_header) ?;
3152+ write_small_section_header ( w, "synthetic-implementors" , "Auto implementors" ,
3153+ "<div class='item-list' id='synthetic-implementors-list'>" ) ?;
31683154 for implementor in synthetic {
31693155 synthetic_types. extend (
31703156 collect_paths_for_type ( implementor. inner_impl ( ) . for_ . clone ( ) )
31713157 ) ;
31723158 render_implementor ( cx, implementor, w, & implementor_dups) ?;
31733159 }
3174- write ! ( w, "</div>" ) ?;
3160+ write_loading_content ( w, "</div>" ) ?;
31753161 }
31763162 } else {
31773163 // even without any implementations to write in, we still want the heading and list, so the
31783164 // implementors javascript file pulled in below has somewhere to write the impls into
3179- write ! ( w, "{}" , impl_header) ?;
3180- write ! ( w, "</div>" ) ?;
3165+ write_small_section_header ( w, "implementors" , "Implementors" ,
3166+ "<div class='item-list' id='implementors-list'>" ) ?;
3167+ write_loading_content ( w, "</div>" ) ?;
31813168
31823169 if t. auto {
3183- write ! ( w, "{}" , synthetic_impl_header) ?;
3184- write ! ( w, "</div>" ) ?;
3170+ write_small_section_header ( w, "synthetic-implementors" , "Auto implementors" ,
3171+ "<div class='item-list' id='synthetic-implementors-list'>" ) ?;
3172+ write_loading_content ( w, "</div>" ) ?;
31853173 }
31863174 }
31873175 write ! ( w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"# ,
0 commit comments