@@ -443,17 +443,36 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
443443 } else {
444444 // FIXME: we should be using a derived_id for the Anchors here
445445 w. write_str ( "{\n " ) ;
446+ let mut toggle = false ;
447+
448+ // If there are too many associated types, hide _everything_
449+ if should_hide_fields ( types. len ( ) ) {
450+ toggle = true ;
451+ toggle_open ( w, "associated items" ) ;
452+ }
446453 for t in & types {
447454 render_assoc_item ( w, t, AssocItemLink :: Anchor ( None ) , ItemType :: Trait , cx) ;
448455 w. write_str ( ";\n " ) ;
449456 }
457+ // If there are too many associated constants, hide everything after them
458+ // We also do this if the types + consts is large because otherwise we could
459+ // render a bunch of types and _then_ a bunch of consts just because both were
460+ // _just_ under the limit
461+ if !toggle & should_hide_fields ( types. len ( ) + consts. len ( ) ) {
462+ toggle = true ;
463+ toggle_open ( w, "associated constants and methods" ) ;
464+ }
450465 if !types. is_empty ( ) && !consts. is_empty ( ) {
451466 w. write_str ( "\n " ) ;
452467 }
453468 for t in & consts {
454469 render_assoc_item ( w, t, AssocItemLink :: Anchor ( None ) , ItemType :: Trait , cx) ;
455470 w. write_str ( ";\n " ) ;
456471 }
472+ if !toggle & should_hide_fields ( required. len ( ) + provided. len ( ) ) {
473+ toggle = true ;
474+ toggle_open ( w, "methods" ) ;
475+ }
457476 if !consts. is_empty ( ) && !required. is_empty ( ) {
458477 w. write_str ( "\n " ) ;
459478 }
@@ -484,6 +503,9 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
484503 w. write_str ( "<div class=\" item-spacer\" ></div>" ) ;
485504 }
486505 }
506+ if toggle {
507+ toggle_close ( w) ;
508+ }
487509 w. write_str ( "}" ) ;
488510 }
489511 w. write_str ( "</pre>" )
@@ -1284,9 +1306,7 @@ fn render_union(
12841306 write ! ( w, " {{\n {}" , tab) ;
12851307 let count_fields = fields
12861308 . iter ( )
1287- . filter (
1288- |f| if let clean:: StructFieldItem ( ..) = * f. kind { true } else { false } ,
1289- )
1309+ . filter ( |f| if let clean:: StructFieldItem ( ..) = * f. kind { true } else { false } )
12901310 . count ( ) ;
12911311 let toggle = should_hide_fields ( count_fields) ;
12921312 if toggle {
@@ -1343,9 +1363,7 @@ fn render_struct(
13431363 w. write_str ( " {" ) ;
13441364 let count_fields = fields
13451365 . iter ( )
1346- . filter (
1347- |f| if let clean:: StructFieldItem ( ..) = * f. kind { true } else { false } ,
1348- )
1366+ . filter ( |f| if let clean:: StructFieldItem ( ..) = * f. kind { true } else { false } )
13491367 . count ( ) ;
13501368 let has_visible_fields = count_fields > 0 ;
13511369 let toggle = should_hide_fields ( count_fields) ;
0 commit comments