@@ -2,7 +2,6 @@ use std::cmp::Ordering;
22use std:: fmt;
33use std:: fmt:: { Display , Write } ;
44
5- use itertools:: Itertools ;
65use rinja:: Template ;
76use rustc_abi:: VariantIdx ;
87use rustc_data_structures:: captures:: Captures ;
@@ -499,11 +498,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
499498 class = myitem. type_( ) ,
500499 unsafety_flag = unsafety_flag,
501500 href = item_path( myitem. type_( ) , myitem. name. unwrap( ) . as_str( ) ) ,
502- title = [ myitem. type_( ) . to_string( ) , full_path( cx, myitem) ]
503- . iter( )
504- . filter_map( |s| if !s. is_empty( ) { Some ( s. as_str( ) ) } else { None } )
505- . collect:: <Vec <_>>( )
506- . join( " " ) ,
501+ title = format_args!( "{} {}" , myitem. type_( ) , full_path( cx, myitem) ) ,
507502 ) ;
508503 }
509504 }
@@ -883,7 +878,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
883878 write ! (
884879 w,
885880 "<div class=\" stab must_implement\" >At least one of the `{}` methods is required.</div>" ,
886- list. iter( ) . join ( "`, `" )
881+ fmt :: from_fn ( |f| list. iter( ) . joined ( "`, `" , f ) )
887882 ) ;
888883 }
889884
@@ -1129,18 +1124,15 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
11291124 js_src_path. extend ( cx. current . iter ( ) . copied ( ) ) ;
11301125 js_src_path. push_fmt ( format_args ! ( "{}.{}.js" , it. type_( ) , it. name. unwrap( ) ) ) ;
11311126 }
1132- let extern_crates = extern_crates
1133- . into_iter ( )
1134- . map ( |cnum| tcx. crate_name ( cnum) . to_string ( ) )
1135- . collect :: < Vec < _ > > ( )
1136- . join ( "," ) ;
1137- let ( extern_before, extern_after) =
1138- if extern_crates. is_empty ( ) { ( "" , "" ) } else { ( " data-ignore-extern-crates=\" " , "\" " ) } ;
1139- write ! (
1140- w,
1141- "<script src=\" {src}\" {extern_before}{extern_crates}{extern_after} async></script>" ,
1142- src = js_src_path. finish( ) ,
1143- ) ;
1127+ let extern_crates = fmt:: from_fn ( |f| {
1128+ if !extern_crates. is_empty ( ) {
1129+ f. write_str ( " data-ignore-extern-crates=\" " ) ?;
1130+ extern_crates. iter ( ) . map ( |& cnum| tcx. crate_name ( cnum) ) . joined ( "," , f) ?;
1131+ f. write_str ( "\" " ) ?;
1132+ }
1133+ Ok ( ( ) )
1134+ } ) ;
1135+ write ! ( w, "<script src=\" {src}\" {extern_crates} async></script>" , src = js_src_path. finish( ) , ) ;
11441136}
11451137
11461138fn item_trait_alias (
@@ -1351,7 +1343,7 @@ fn item_type_alias(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean
13511343 . collect ( ) ;
13521344 js_src_path. extend ( target_fqp[ ..target_fqp. len ( ) - 1 ] . iter ( ) . copied ( ) ) ;
13531345 js_src_path. push_fmt ( format_args ! ( "{target_type}.{}.js" , target_fqp. last( ) . unwrap( ) ) ) ;
1354- let self_path = self_fqp. iter ( ) . map ( Symbol :: as_str ) . collect :: < Vec < & str > > ( ) . join ( "::" ) ;
1346+ let self_path = fmt :: from_fn ( |f| self_fqp. iter ( ) . joined ( "::" , f ) ) ;
13551347 write ! (
13561348 w,
13571349 "<script src=\" {src}\" data-self-path=\" {self_path}\" async></script>" ,
@@ -2290,18 +2282,29 @@ fn render_struct_fields(
22902282 {
22912283 write ! ( w, "<span class=\" comment\" >/* private fields */</span>" ) ;
22922284 } else {
2293- for ( i, field) in fields. iter ( ) . enumerate ( ) {
2294- if i > 0 {
2295- w. write_str ( ", " ) ;
2296- }
2297- match field. kind {
2298- clean:: StrippedItem ( box clean:: StructFieldItem ( ..) ) => write ! ( w, "_" ) ,
2299- clean:: StructFieldItem ( ref ty) => {
2300- write ! ( w, "{}{}" , visibility_print_with_space( field, cx) , ty. print( cx) , )
2301- }
2302- _ => unreachable ! ( ) ,
2303- }
2304- }
2285+ write ! (
2286+ w,
2287+ "{}" ,
2288+ fmt:: from_fn( |f| fields
2289+ . iter( )
2290+ . map( |field| {
2291+ fmt:: from_fn( |f| match field. kind {
2292+ clean:: StrippedItem ( box clean:: StructFieldItem ( ..) ) => {
2293+ write!( f, "_" )
2294+ }
2295+ clean:: StructFieldItem ( ref ty) => {
2296+ write!(
2297+ f,
2298+ "{}{}" ,
2299+ visibility_print_with_space( field, cx) ,
2300+ ty. print( cx)
2301+ )
2302+ }
2303+ _ => unreachable!( ) ,
2304+ } )
2305+ } )
2306+ . joined( ", " , f) )
2307+ ) ;
23052308 }
23062309 w. write_str ( ")" ) ;
23072310 if let Some ( g) = g {
0 commit comments