@@ -711,13 +711,15 @@ fn render_impls(
711711 containing_item,
712712 assoc_link,
713713 RenderMode :: Normal ,
714- true ,
715714 None ,
716- false ,
717- true ,
718- true ,
719715 & [ ] ,
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+ } ,
721723 ) ;
722724 buffer. into_inner ( )
723725 } )
@@ -1052,13 +1054,15 @@ fn render_assoc_items(
10521054 containing_item,
10531055 AssocItemLink :: Anchor ( None ) ,
10541056 render_mode,
1055- true ,
10561057 None ,
1057- false ,
1058- true ,
1059- true ,
10601058 & [ ] ,
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+ } ,
10621066 ) ;
10631067 }
10641068 }
@@ -1248,23 +1252,26 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
12481252 out. into_inner ( )
12491253}
12501254
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+
12511265fn render_impl (
12521266 w : & mut Buffer ,
12531267 cx : & Context < ' _ > ,
12541268 i : & Impl ,
12551269 parent : & clean:: Item ,
12561270 link : AssocItemLink < ' _ > ,
12571271 render_mode : RenderMode ,
1258- show_def_docs : bool ,
12591272 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".
12661273 aliases : & [ String ] ,
1267- toggle_open_by_default : bool ,
1274+ rendering_params : ImplRenderingParameters ,
12681275) {
12691276 let cache = cx. cache ( ) ;
12701277 let traits = & cache. traits ;
@@ -1287,13 +1294,12 @@ fn render_impl(
12871294 render_mode : RenderMode ,
12881295 is_default_item : bool ,
12891296 trait_ : Option < & clean:: Trait > ,
1290- show_def_docs : bool ,
1291- show_non_assoc_items : bool ,
1297+ rendering_params : ImplRenderingParameters ,
12921298 ) {
12931299 let item_type = item. type_ ( ) ;
12941300 let name = item. name . as_ref ( ) . unwrap ( ) ;
12951301
1296- let render_method_item = show_non_assoc_items
1302+ let render_method_item = rendering_params . show_non_assoc_items
12971303 && match render_mode {
12981304 RenderMode :: Normal => true ,
12991305 RenderMode :: ForDeref { mut_ : deref_mut_ } => {
@@ -1322,18 +1328,32 @@ fn render_impl(
13221328 } else {
13231329 // In case the item isn't documented,
13241330 // 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+ ) ;
13261339 }
13271340 }
13281341 } else {
13291342 document_item_info ( & mut info_buffer, cx, item, Some ( parent) ) ;
1330- if show_def_docs {
1343+ if rendering_params . show_def_docs {
13311344 document_full ( & mut doc_buffer, item, cx) ;
13321345 short_documented = false ;
13331346 }
13341347 }
13351348 } 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+ ) ;
13371357 }
13381358 }
13391359 let w = if short_documented && trait_. is_some ( ) { interesting } else { boring } ;
@@ -1465,8 +1485,7 @@ fn render_impl(
14651485 render_mode,
14661486 false ,
14671487 trait_. map ( |t| & t. trait_ ) ,
1468- show_def_docs,
1469- show_non_assoc_items,
1488+ rendering_params,
14701489 ) ;
14711490 }
14721491
@@ -1479,8 +1498,7 @@ fn render_impl(
14791498 parent : & clean:: Item ,
14801499 containing_item : & clean:: Item ,
14811500 render_mode : RenderMode ,
1482- show_def_docs : bool ,
1483- show_non_assoc_items : bool ,
1501+ rendering_params : ImplRenderingParameters ,
14841502 ) {
14851503 for trait_item in & t. items {
14861504 let n = trait_item. name ;
@@ -1502,8 +1520,7 @@ fn render_impl(
15021520 render_mode,
15031521 true ,
15041522 Some ( t) ,
1505- show_def_docs,
1506- show_non_assoc_items,
1523+ rendering_params,
15071524 ) ;
15081525 }
15091526 }
@@ -1512,7 +1529,7 @@ fn render_impl(
15121529 // default items which weren't overridden in the implementation block.
15131530 // We don't emit documentation for default items if they appear in the
15141531 // Implementations on Foreign Types or Implementors sections.
1515- if show_default_items {
1532+ if rendering_params . show_default_items {
15161533 if let Some ( t) = trait_ {
15171534 render_default_items (
15181535 & mut default_impl_items,
@@ -1523,8 +1540,7 @@ fn render_impl(
15231540 & i. impl_item ,
15241541 parent,
15251542 render_mode,
1526- show_def_docs,
1527- show_non_assoc_items,
1543+ rendering_params,
15281544 ) ;
15291545 }
15301546 }
@@ -1535,7 +1551,7 @@ fn render_impl(
15351551 write ! (
15361552 w,
15371553 "<details class=\" rustdoc-toggle implementors-toggle\" {}>" ,
1538- if toggle_open_by_default { " open" } else { "" }
1554+ if rendering_params . toggle_open_by_default { " open" } else { "" }
15391555 ) ;
15401556 write ! ( w, "<summary>" )
15411557 }
@@ -1545,9 +1561,9 @@ fn render_impl(
15451561 i,
15461562 parent,
15471563 parent,
1548- show_def_docs,
1564+ rendering_params . show_def_docs ,
15491565 use_absolute,
1550- is_on_foreign_type,
1566+ rendering_params . is_on_foreign_type ,
15511567 aliases,
15521568 ) ;
15531569 if toggled {
0 commit comments