@@ -3016,6 +3016,22 @@ fn item_trait(
3016
3016
// Trait documentation
3017
3017
document ( w, cx, it) ?;
3018
3018
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
+
3019
3035
fn trait_item ( w : & mut fmt:: Formatter , cx : & Context , m : & clean:: Item , t : & clean:: Item )
3020
3036
-> fmt:: Result {
3021
3037
let name = m. name . as_ref ( ) . unwrap ( ) ;
@@ -3036,74 +3052,45 @@ fn item_trait(
3036
3052
}
3037
3053
3038
3054
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'>" ) ?;
3045
3057
for t in & types {
3046
3058
trait_item ( w, cx, * t, it) ?;
3047
3059
}
3048
- write ! ( w, "</div>" ) ?;
3060
+ write_loading_content ( w, "</div>" ) ?;
3049
3061
}
3050
3062
3051
3063
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'>" ) ?;
3058
3066
for t in & consts {
3059
3067
trait_item ( w, cx, * t, it) ?;
3060
3068
}
3061
- write ! ( w, "</div>" ) ?;
3069
+ write_loading_content ( w, "</div>" ) ?;
3062
3070
}
3063
3071
3064
3072
// Output the documentation for each function individually
3065
3073
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'>" ) ?;
3072
3076
for m in & required {
3073
3077
trait_item ( w, cx, * m, it) ?;
3074
3078
}
3075
- write ! ( w, "</div>" ) ?;
3079
+ write_loading_content ( w, "</div>" ) ?;
3076
3080
}
3077
3081
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'>" ) ?;
3084
3084
for m in & provided {
3085
3085
trait_item ( w, cx, * m, it) ?;
3086
3086
}
3087
- write ! ( w, "</div>" ) ?;
3087
+ write_loading_content ( w, "</div>" ) ?;
3088
3088
}
3089
3089
3090
3090
// If there are methods directly on this trait object, render them here.
3091
3091
render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All ) ?;
3092
3092
3093
3093
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
- ";
3107
3094
3108
3095
let mut synthetic_types = Vec :: new ( ) ;
3109
3096
@@ -3140,11 +3127,7 @@ fn item_trait(
3140
3127
concrete. sort_by ( compare_impl) ;
3141
3128
3142
3129
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" , "" ) ?;
3148
3131
3149
3132
for implementor in foreign {
3150
3133
let assoc_link = AssocItemLink :: GotoSource (
@@ -3155,33 +3138,38 @@ fn item_trait(
3155
3138
RenderMode :: Normal , implementor. impl_item . stable_since ( ) , false ,
3156
3139
None ) ?;
3157
3140
}
3141
+ write_loading_content ( w, "" ) ?;
3158
3142
}
3159
3143
3160
- write ! ( w, "{}" , impl_header) ?;
3144
+ write_small_section_header ( w, "implementors" , "Implementors" ,
3145
+ "<div class='item-list' id='implementors-list'>" ) ?;
3161
3146
for implementor in concrete {
3162
3147
render_implementor ( cx, implementor, w, & implementor_dups) ?;
3163
3148
}
3164
- write ! ( w, "</div>" ) ?;
3149
+ write_loading_content ( w, "</div>" ) ?;
3165
3150
3166
3151
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'>" ) ?;
3168
3154
for implementor in synthetic {
3169
3155
synthetic_types. extend (
3170
3156
collect_paths_for_type ( implementor. inner_impl ( ) . for_ . clone ( ) )
3171
3157
) ;
3172
3158
render_implementor ( cx, implementor, w, & implementor_dups) ?;
3173
3159
}
3174
- write ! ( w, "</div>" ) ?;
3160
+ write_loading_content ( w, "</div>" ) ?;
3175
3161
}
3176
3162
} else {
3177
3163
// even without any implementations to write in, we still want the heading and list, so the
3178
3164
// 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>" ) ?;
3181
3168
3182
3169
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>" ) ?;
3185
3173
}
3186
3174
}
3187
3175
write ! ( w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"# ,
0 commit comments