@@ -1174,17 +1174,23 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
1174
1174
document_type_layout ( w, cx, def_id) ;
1175
1175
}
1176
1176
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
+ }
1186
1191
}
1187
- }
1192
+ Ok ( ( ) )
1193
+ } )
1188
1194
}
1189
1195
1190
1196
fn 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::
1221
1227
clean:: VariantItem ( ref var) => match var. kind {
1222
1228
clean:: VariantKind :: CLike => write ! ( w, "{}" , name) ,
1223
1229
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) , ) ;
1227
1231
}
1228
1232
clean:: VariantKind :: Struct ( ref s) => {
1229
1233
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::
1276
1280
let clean:: VariantItem ( variant_data) = & * variant. kind else { unreachable ! ( ) } ;
1277
1281
1278
1282
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) , ) ;
1282
1284
}
1283
1285
w. write_str ( "</h3></section>" ) ;
1284
1286
0 commit comments