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