@@ -709,13 +709,15 @@ fn render_impls(
709709 containing_item,
710710 assoc_link,
711711 RenderMode :: Normal ,
712- true ,
713712 None ,
714- false ,
715- true ,
716- true ,
717713 & [ ] ,
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+ } ,
719721 ) ;
720722 buffer. into_inner ( )
721723 } )
@@ -1050,13 +1052,15 @@ fn render_assoc_items(
10501052 containing_item,
10511053 AssocItemLink :: Anchor ( None ) ,
10521054 render_mode,
1053- true ,
10541055 None ,
1055- false ,
1056- true ,
1057- true ,
10581056 & [ ] ,
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+ } ,
10601064 ) ;
10611065 }
10621066 }
@@ -1245,23 +1249,26 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
12451249 out. into_inner ( )
12461250}
12471251
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+
12481262fn render_impl (
12491263 w : & mut Buffer ,
12501264 cx : & Context < ' _ > ,
12511265 i : & Impl ,
12521266 parent : & clean:: Item ,
12531267 link : AssocItemLink < ' _ > ,
12541268 render_mode : RenderMode ,
1255- show_def_docs : bool ,
12561269 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".
12631270 aliases : & [ String ] ,
1264- toggle_open_by_default : bool ,
1271+ rendering_params : ImplRenderingParameters ,
12651272) {
12661273 let cache = cx. cache ( ) ;
12671274 let traits = & cache. traits ;
@@ -1284,13 +1291,12 @@ fn render_impl(
12841291 render_mode : RenderMode ,
12851292 is_default_item : bool ,
12861293 trait_ : Option < & clean:: Trait > ,
1287- show_def_docs : bool ,
1288- show_non_assoc_items : bool ,
1294+ rendering_params : ImplRenderingParameters ,
12891295 ) {
12901296 let item_type = item. type_ ( ) ;
12911297 let name = item. name . as_ref ( ) . unwrap ( ) ;
12921298
1293- let render_method_item = show_non_assoc_items
1299+ let render_method_item = rendering_params . show_non_assoc_items
12941300 && match render_mode {
12951301 RenderMode :: Normal => true ,
12961302 RenderMode :: ForDeref { mut_ : deref_mut_ } => {
@@ -1319,18 +1325,32 @@ fn render_impl(
13191325 } else {
13201326 // In case the item isn't documented,
13211327 // 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+ ) ;
13231336 }
13241337 }
13251338 } else {
13261339 document_item_info ( & mut info_buffer, cx, item, Some ( parent) ) ;
1327- if show_def_docs {
1340+ if rendering_params . show_def_docs {
13281341 document_full ( & mut doc_buffer, item, cx) ;
13291342 short_documented = false ;
13301343 }
13311344 }
13321345 } 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+ ) ;
13341354 }
13351355 }
13361356 let w = if short_documented && trait_. is_some ( ) { interesting } else { boring } ;
@@ -1462,8 +1482,7 @@ fn render_impl(
14621482 render_mode,
14631483 false ,
14641484 trait_. map ( |t| & t. trait_ ) ,
1465- show_def_docs,
1466- show_non_assoc_items,
1485+ rendering_params,
14671486 ) ;
14681487 }
14691488
@@ -1476,8 +1495,7 @@ fn render_impl(
14761495 parent : & clean:: Item ,
14771496 containing_item : & clean:: Item ,
14781497 render_mode : RenderMode ,
1479- show_def_docs : bool ,
1480- show_non_assoc_items : bool ,
1498+ rendering_params : ImplRenderingParameters ,
14811499 ) {
14821500 for trait_item in & t. items {
14831501 let n = trait_item. name ;
@@ -1499,8 +1517,7 @@ fn render_impl(
14991517 render_mode,
15001518 true ,
15011519 Some ( t) ,
1502- show_def_docs,
1503- show_non_assoc_items,
1520+ rendering_params,
15041521 ) ;
15051522 }
15061523 }
@@ -1509,7 +1526,7 @@ fn render_impl(
15091526 // default items which weren't overridden in the implementation block.
15101527 // We don't emit documentation for default items if they appear in the
15111528 // Implementations on Foreign Types or Implementors sections.
1512- if show_default_items {
1529+ if rendering_params . show_default_items {
15131530 if let Some ( t) = trait_ {
15141531 render_default_items (
15151532 & mut default_impl_items,
@@ -1520,8 +1537,7 @@ fn render_impl(
15201537 & i. impl_item ,
15211538 parent,
15221539 render_mode,
1523- show_def_docs,
1524- show_non_assoc_items,
1540+ rendering_params,
15251541 ) ;
15261542 }
15271543 }
@@ -1532,7 +1548,7 @@ fn render_impl(
15321548 write ! (
15331549 w,
15341550 "<details class=\" rustdoc-toggle implementors-toggle\" {}>" ,
1535- if toggle_open_by_default { " open" } else { "" }
1551+ if rendering_params . toggle_open_by_default { " open" } else { "" }
15361552 ) ;
15371553 write ! ( w, "<summary>" )
15381554 }
@@ -1542,9 +1558,9 @@ fn render_impl(
15421558 i,
15431559 parent,
15441560 parent,
1545- show_def_docs,
1561+ rendering_params . show_def_docs ,
15461562 use_absolute,
1547- is_on_foreign_type,
1563+ rendering_params . is_on_foreign_type ,
15481564 aliases,
15491565 ) ;
15501566 if toggled {
0 commit comments