@@ -1457,8 +1457,8 @@ fn render_impl(
1457
1457
}
1458
1458
1459
1459
fn render_default_items (
1460
- w : & mut Buffer ,
1461
- tmp_w : & mut Buffer ,
1460
+ boring : & mut Buffer ,
1461
+ interesting : & mut Buffer ,
1462
1462
cx : & Context < ' _ > ,
1463
1463
t : & clean:: Trait ,
1464
1464
i : & clean:: Impl ,
@@ -1477,8 +1477,8 @@ fn render_impl(
1477
1477
let assoc_link = AssocItemLink :: GotoSource ( did, & i. provided_trait_methods ) ;
1478
1478
1479
1479
doc_impl_item (
1480
- w ,
1481
- tmp_w ,
1480
+ boring ,
1481
+ interesting ,
1482
1482
cx,
1483
1483
trait_item,
1484
1484
parent,
@@ -1513,10 +1513,14 @@ fn render_impl(
1513
1513
) ;
1514
1514
}
1515
1515
}
1516
- let details_str = if impl_items. is_empty ( ) && default_impl_items. is_empty ( ) {
1517
- ""
1518
- } else {
1519
- "<details class=\" rustdoc-toggle implementors-toggle\" open><summary>"
1516
+ let toggled = !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) ;
1517
+ let open_details = |close_tags : & mut String | {
1518
+ if toggled {
1519
+ close_tags. insert_str ( 0 , "</details>" ) ;
1520
+ "<details class=\" rustdoc-toggle implementors-toggle\" open><summary>"
1521
+ } else {
1522
+ ""
1523
+ }
1520
1524
} ;
1521
1525
if render_mode == RenderMode :: Normal {
1522
1526
let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
@@ -1538,11 +1542,10 @@ fn render_impl(
1538
1542
write ! (
1539
1543
w,
1540
1544
"{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >" ,
1541
- details_str, id, aliases
1545
+ open_details( & mut close_tags) ,
1546
+ id,
1547
+ aliases
1542
1548
) ;
1543
- if !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) {
1544
- close_tags. insert_str ( 0 , "</details>" ) ;
1545
- }
1546
1549
write ! ( w, "{}" , i. inner_impl( ) . print( use_absolute, cx) ) ;
1547
1550
if show_def_docs {
1548
1551
for it in & i. inner_impl ( ) . items {
@@ -1566,14 +1569,11 @@ fn render_impl(
1566
1569
write ! (
1567
1570
w,
1568
1571
"{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >{}</code>" ,
1569
- details_str ,
1572
+ open_details ( & mut close_tags ) ,
1570
1573
id,
1571
1574
aliases,
1572
1575
i. inner_impl( ) . print( false , cx)
1573
1576
) ;
1574
- if !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) {
1575
- close_tags. insert_str ( 0 , "</details>" ) ;
1576
- }
1577
1577
}
1578
1578
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1579
1579
render_stability_since_raw (
@@ -1584,7 +1584,7 @@ fn render_impl(
1584
1584
outer_const_version,
1585
1585
) ;
1586
1586
write_srclink ( cx, & i. impl_item , w) ;
1587
- if impl_items . is_empty ( ) && default_impl_items . is_empty ( ) {
1587
+ if !toggled {
1588
1588
w. write_str ( "</h3>" ) ;
1589
1589
} else {
1590
1590
w. write_str ( "</h3></summary>" ) ;
@@ -1613,7 +1613,7 @@ fn render_impl(
1613
1613
) ;
1614
1614
}
1615
1615
}
1616
- if !impl_items . is_empty ( ) || !default_impl_items . is_empty ( ) {
1616
+ if toggled {
1617
1617
w. write_str ( "<div class=\" impl-items\" >" ) ;
1618
1618
w. push_buffer ( default_impl_items) ;
1619
1619
if trait_. is_some ( ) && !impl_items. is_empty ( ) {
0 commit comments