@@ -1174,17 +1174,23 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
11741174 document_type_layout ( w, cx, def_id) ;
11751175}
11761176
1177- fn print_tuple_struct_fields ( w : & mut Buffer , cx : & Context < ' _ > , s : & [ clean:: Item ] ) {
1178- for ( i, ty) in s. iter ( ) . enumerate ( ) {
1179- if i > 0 {
1180- w. write_str ( ", " ) ;
1181- }
1182- match * ty. kind {
1183- clean:: StrippedItem ( box clean:: StructFieldItem ( _) ) => w. write_str ( "_" ) ,
1184- clean:: StructFieldItem ( ref ty) => write ! ( w, "{}" , ty. print( cx) ) ,
1185- _ => unreachable ! ( ) ,
1177+ fn print_tuple_struct_fields < ' a , ' cx : ' a > (
1178+ cx : & ' a Context < ' cx > ,
1179+ s : & ' a [ clean:: Item ] ,
1180+ ) -> impl fmt:: Display + ' a + Captures < ' cx > {
1181+ display_fn ( |f| {
1182+ for ( i, ty) in s. iter ( ) . enumerate ( ) {
1183+ if i > 0 {
1184+ f. write_str ( ", " ) ?;
1185+ }
1186+ match * ty. kind {
1187+ clean:: StrippedItem ( box clean:: StructFieldItem ( _) ) => f. write_str ( "_" ) ?,
1188+ clean:: StructFieldItem ( ref ty) => write ! ( f, "{}" , ty. print( cx) ) ?,
1189+ _ => unreachable ! ( ) ,
1190+ }
11861191 }
1187- }
1192+ Ok ( ( ) )
1193+ } )
11881194}
11891195
11901196fn item_enum ( w : & mut Buffer , cx : & mut Context < ' _ > , it : & clean:: Item , e : & clean:: Enum ) {
@@ -1221,9 +1227,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
12211227 clean:: VariantItem ( ref var) => match var. kind {
12221228 clean:: VariantKind :: CLike => write ! ( w, "{}" , name) ,
12231229 clean:: VariantKind :: Tuple ( ref s) => {
1224- write ! ( w, "{}(" , name) ;
1225- print_tuple_struct_fields ( w, cx, s) ;
1226- w. write_str ( ")" ) ;
1230+ write ! ( w, "{name}({})" , print_tuple_struct_fields( cx, s) , ) ;
12271231 }
12281232 clean:: VariantKind :: Struct ( ref s) => {
12291233 render_struct ( w, v, None , None , & s. fields , " " , false , cx) ;
@@ -1276,9 +1280,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
12761280 let clean:: VariantItem ( variant_data) = & * variant. kind else { unreachable ! ( ) } ;
12771281
12781282 if let clean:: VariantKind :: Tuple ( ref s) = variant_data. kind {
1279- w. write_str ( "(" ) ;
1280- print_tuple_struct_fields ( w, cx, s) ;
1281- w. write_str ( ")" ) ;
1283+ write ! ( w, "({})" , print_tuple_struct_fields( cx, s) , ) ;
12821284 }
12831285 w. write_str ( "</h3></section>" ) ;
12841286
0 commit comments