@@ -709,13 +709,15 @@ fn render_impls(
709
709
containing_item,
710
710
assoc_link,
711
711
RenderMode :: Normal ,
712
- true ,
713
712
None ,
714
- false ,
715
- true ,
716
- true ,
717
713
& [ ] ,
718
- true ,
714
+ ImplRenderingParameters {
715
+ show_def_docs : true ,
716
+ is_on_foreign_type : false ,
717
+ show_default_items : true ,
718
+ show_non_assoc_items : true ,
719
+ toggle_open_by_default : true ,
720
+ } ,
719
721
) ;
720
722
buffer. into_inner ( )
721
723
} )
@@ -1050,13 +1052,15 @@ fn render_assoc_items(
1050
1052
containing_item,
1051
1053
AssocItemLink :: Anchor ( None ) ,
1052
1054
render_mode,
1053
- true ,
1054
1055
None ,
1055
- false ,
1056
- true ,
1057
- true ,
1058
1056
& [ ] ,
1059
- true ,
1057
+ ImplRenderingParameters {
1058
+ show_def_docs : true ,
1059
+ is_on_foreign_type : false ,
1060
+ show_default_items : true ,
1061
+ show_non_assoc_items : true ,
1062
+ toggle_open_by_default : true ,
1063
+ } ,
1060
1064
) ;
1061
1065
}
1062
1066
}
@@ -1245,23 +1249,26 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
1245
1249
out. into_inner ( )
1246
1250
}
1247
1251
1252
+ #[ derive( Clone , Copy , Debug ) ]
1253
+ struct ImplRenderingParameters {
1254
+ show_def_docs : bool ,
1255
+ is_on_foreign_type : bool ,
1256
+ show_default_items : bool ,
1257
+ /// Whether or not to show methods.
1258
+ show_non_assoc_items : bool ,
1259
+ toggle_open_by_default : bool ,
1260
+ }
1261
+
1248
1262
fn render_impl (
1249
1263
w : & mut Buffer ,
1250
1264
cx : & Context < ' _ > ,
1251
1265
i : & Impl ,
1252
1266
parent : & clean:: Item ,
1253
1267
link : AssocItemLink < ' _ > ,
1254
1268
render_mode : RenderMode ,
1255
- show_def_docs : bool ,
1256
1269
use_absolute : Option < bool > ,
1257
- is_on_foreign_type : bool ,
1258
- show_default_items : bool ,
1259
- // It'll exclude methods.
1260
- show_non_assoc_items : bool ,
1261
- // This argument is used to reference same type with different paths to avoid duplication
1262
- // in documentation pages for trait with automatic implementations like "Send" and "Sync".
1263
1270
aliases : & [ String ] ,
1264
- toggle_open_by_default : bool ,
1271
+ rendering_params : ImplRenderingParameters ,
1265
1272
) {
1266
1273
let cache = cx. cache ( ) ;
1267
1274
let traits = & cache. traits ;
@@ -1284,13 +1291,12 @@ fn render_impl(
1284
1291
render_mode : RenderMode ,
1285
1292
is_default_item : bool ,
1286
1293
trait_ : Option < & clean:: Trait > ,
1287
- show_def_docs : bool ,
1288
- show_non_assoc_items : bool ,
1294
+ rendering_params : ImplRenderingParameters ,
1289
1295
) {
1290
1296
let item_type = item. type_ ( ) ;
1291
1297
let name = item. name . as_ref ( ) . unwrap ( ) ;
1292
1298
1293
- let render_method_item = show_non_assoc_items
1299
+ let render_method_item = rendering_params . show_non_assoc_items
1294
1300
&& match render_mode {
1295
1301
RenderMode :: Normal => true ,
1296
1302
RenderMode :: ForDeref { mut_ : deref_mut_ } => {
@@ -1319,18 +1325,32 @@ fn render_impl(
1319
1325
} else {
1320
1326
// In case the item isn't documented,
1321
1327
// provide short documentation from the trait.
1322
- document_short ( & mut doc_buffer, it, cx, link, parent, show_def_docs) ;
1328
+ document_short (
1329
+ & mut doc_buffer,
1330
+ it,
1331
+ cx,
1332
+ link,
1333
+ parent,
1334
+ rendering_params. show_def_docs ,
1335
+ ) ;
1323
1336
}
1324
1337
}
1325
1338
} else {
1326
1339
document_item_info ( & mut info_buffer, cx, item, Some ( parent) ) ;
1327
- if show_def_docs {
1340
+ if rendering_params . show_def_docs {
1328
1341
document_full ( & mut doc_buffer, item, cx) ;
1329
1342
short_documented = false ;
1330
1343
}
1331
1344
}
1332
1345
} else {
1333
- document_short ( & mut doc_buffer, item, cx, link, parent, show_def_docs) ;
1346
+ document_short (
1347
+ & mut doc_buffer,
1348
+ item,
1349
+ cx,
1350
+ link,
1351
+ parent,
1352
+ rendering_params. show_def_docs ,
1353
+ ) ;
1334
1354
}
1335
1355
}
1336
1356
let w = if short_documented && trait_. is_some ( ) { interesting } else { boring } ;
@@ -1462,8 +1482,7 @@ fn render_impl(
1462
1482
render_mode,
1463
1483
false ,
1464
1484
trait_. map ( |t| & t. trait_ ) ,
1465
- show_def_docs,
1466
- show_non_assoc_items,
1485
+ rendering_params,
1467
1486
) ;
1468
1487
}
1469
1488
@@ -1476,8 +1495,7 @@ fn render_impl(
1476
1495
parent : & clean:: Item ,
1477
1496
containing_item : & clean:: Item ,
1478
1497
render_mode : RenderMode ,
1479
- show_def_docs : bool ,
1480
- show_non_assoc_items : bool ,
1498
+ rendering_params : ImplRenderingParameters ,
1481
1499
) {
1482
1500
for trait_item in & t. items {
1483
1501
let n = trait_item. name ;
@@ -1499,8 +1517,7 @@ fn render_impl(
1499
1517
render_mode,
1500
1518
true ,
1501
1519
Some ( t) ,
1502
- show_def_docs,
1503
- show_non_assoc_items,
1520
+ rendering_params,
1504
1521
) ;
1505
1522
}
1506
1523
}
@@ -1509,7 +1526,7 @@ fn render_impl(
1509
1526
// default items which weren't overridden in the implementation block.
1510
1527
// We don't emit documentation for default items if they appear in the
1511
1528
// Implementations on Foreign Types or Implementors sections.
1512
- if show_default_items {
1529
+ if rendering_params . show_default_items {
1513
1530
if let Some ( t) = trait_ {
1514
1531
render_default_items (
1515
1532
& mut default_impl_items,
@@ -1520,8 +1537,7 @@ fn render_impl(
1520
1537
& i. impl_item ,
1521
1538
parent,
1522
1539
render_mode,
1523
- show_def_docs,
1524
- show_non_assoc_items,
1540
+ rendering_params,
1525
1541
) ;
1526
1542
}
1527
1543
}
@@ -1532,7 +1548,7 @@ fn render_impl(
1532
1548
write ! (
1533
1549
w,
1534
1550
"<details class=\" rustdoc-toggle implementors-toggle\" {}>" ,
1535
- if toggle_open_by_default { " open" } else { "" }
1551
+ if rendering_params . toggle_open_by_default { " open" } else { "" }
1536
1552
) ;
1537
1553
write ! ( w, "<summary>" )
1538
1554
}
@@ -1542,9 +1558,9 @@ fn render_impl(
1542
1558
i,
1543
1559
parent,
1544
1560
parent,
1545
- show_def_docs,
1561
+ rendering_params . show_def_docs ,
1546
1562
use_absolute,
1547
- is_on_foreign_type,
1563
+ rendering_params . is_on_foreign_type ,
1548
1564
aliases,
1549
1565
) ;
1550
1566
if toggled {
0 commit comments