@@ -1334,7 +1334,7 @@ fn item_type_alias(w: &mut String, cx: &Context<'_>, it: &clean::Item, t: &clean
1334
1334
) ,
1335
1335
) ;
1336
1336
} ) ;
1337
- item_fields ( w, cx, it, fields, None ) ;
1337
+ write_str ( w, format_args ! ( "{}" , item_fields ( cx, it, fields, None ) ) ) ;
1338
1338
}
1339
1339
clean:: TypeAliasInnerType :: Struct { ctor_kind, fields } => {
1340
1340
wrap_item ( w, |w| {
@@ -1359,7 +1359,7 @@ fn item_type_alias(w: &mut String, cx: &Context<'_>, it: &clean::Item, t: &clean
1359
1359
) ,
1360
1360
) ;
1361
1361
} ) ;
1362
- item_fields ( w, cx, it, fields, None ) ;
1362
+ write_str ( w, format_args ! ( "{}" , item_fields ( cx, it, fields, None ) ) ) ;
1363
1363
}
1364
1364
}
1365
1365
}
@@ -1993,67 +1993,73 @@ fn item_struct(w: &mut String, cx: &Context<'_>, it: &clean::Item, s: &clean::St
1993
1993
) ;
1994
1994
} ) ;
1995
1995
1996
- write_str ( w, format_args ! ( "{}" , document( cx, it, None , HeadingOffset :: H2 ) ) ) ;
1997
-
1998
- item_fields ( w, cx, it, & s. fields , s. ctor_kind ) ;
1999
-
2000
1996
let def_id = it. item_id . expect_def_id ( ) ;
2001
- write_str ( w, format_args ! ( "{}" , render_assoc_items( cx, it, def_id, AssocItemRender :: All ) ) ) ;
2002
- write_str ( w, format_args ! ( "{}" , document_type_layout( cx, def_id) ) ) ;
1997
+
1998
+ write_str (
1999
+ w,
2000
+ format_args ! (
2001
+ "{}{}{}{}" ,
2002
+ document( cx, it, None , HeadingOffset :: H2 ) ,
2003
+ item_fields( cx, it, & s. fields, s. ctor_kind) ,
2004
+ render_assoc_items( cx, it, def_id, AssocItemRender :: All ) ,
2005
+ document_type_layout( cx, def_id) ,
2006
+ ) ,
2007
+ ) ;
2003
2008
}
2004
2009
2005
- fn item_fields (
2006
- w : & mut String ,
2007
- cx : & Context < ' _ > ,
2008
- it : & clean:: Item ,
2009
- fields : & [ clean:: Item ] ,
2010
+ fn item_fields < ' a , ' tcx > (
2011
+ cx : & ' a Context < ' tcx > ,
2012
+ it : & ' a clean:: Item ,
2013
+ fields : & ' a [ clean:: Item ] ,
2010
2014
ctor_kind : Option < CtorKind > ,
2011
- ) {
2012
- let mut fields = fields
2013
- . iter ( )
2014
- . filter_map ( |f| match f . kind {
2015
- clean :: StructFieldItem ( ref ty ) => Some ( ( f , ty ) ) ,
2016
- _ => None ,
2017
- } )
2018
- . peekable ( ) ;
2019
- if let None | Some ( CtorKind :: Fn ) = ctor_kind {
2020
- if fields . peek ( ) . is_some ( ) {
2021
- let title = format ! (
2022
- "{}{}" ,
2023
- if ctor_kind . is_none ( ) { "Fields" } else { "Tuple Fields" } ,
2024
- document_non_exhaustive_header ( it ) ,
2025
- ) ;
2026
- write_str (
2027
- w ,
2028
- format_args ! (
2015
+ ) -> impl fmt :: Display + ' a + Captures < ' tcx > {
2016
+ fmt :: from_fn ( move |w| {
2017
+ let mut fields = fields
2018
+ . iter ( )
2019
+ . filter_map ( |f| match f . kind {
2020
+ clean :: StructFieldItem ( ref ty ) => Some ( ( f , ty ) ) ,
2021
+ _ => None ,
2022
+ } )
2023
+ . peekable ( ) ;
2024
+ if let None | Some ( CtorKind :: Fn ) = ctor_kind {
2025
+ if fields . peek ( ) . is_some ( ) {
2026
+ let title = format ! (
2027
+ "{}{}" ,
2028
+ if ctor_kind . is_none ( ) { "Fields" } else { "Tuple Fields" } ,
2029
+ document_non_exhaustive_header ( it ) ,
2030
+ ) ;
2031
+ write ! (
2032
+ w ,
2029
2033
"{}" ,
2030
2034
write_section_heading(
2031
2035
& title,
2032
2036
"fields" ,
2033
2037
Some ( "fields" ) ,
2034
2038
document_non_exhaustive( it)
2035
2039
)
2036
- ) ,
2037
- ) ;
2038
- for ( index , ( field , ty ) ) in fields . enumerate ( ) {
2039
- let field_name =
2040
- field . name . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
2041
- let id = cx . derive_id ( format ! ( "{typ}.{field_name}" , typ = ItemType :: StructField ) ) ;
2042
- write_str (
2043
- w ,
2044
- format_args ! (
2040
+ ) ? ;
2041
+ for ( index , ( field , ty ) ) in fields . enumerate ( ) {
2042
+ let field_name = field
2043
+ . name
2044
+ . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
2045
+ let id =
2046
+ cx . derive_id ( format ! ( "{typ}.{field_name}" , typ = ItemType :: StructField ) ) ;
2047
+ write ! (
2048
+ w ,
2045
2049
"<span id=\" {id}\" class=\" {item_type} section-header\" >\
2046
2050
<a href=\" #{id}\" class=\" anchor field\" >§</a>\
2047
2051
<code>{field_name}: {ty}</code>\
2048
- </span>",
2052
+ </span>\
2053
+ {doc}",
2049
2054
item_type = ItemType :: StructField ,
2050
- ty = ty. print( cx)
2051
- ) ,
2052
- ) ;
2053
- write_str ( w , format_args ! ( "{}" , document ( cx , field , Some ( it ) , HeadingOffset :: H3 ) ) ) ;
2055
+ ty = ty. print( cx) ,
2056
+ doc = document ( cx , field , Some ( it ) , HeadingOffset :: H3 ) ,
2057
+ ) ? ;
2058
+ }
2054
2059
}
2055
2060
}
2056
- }
2061
+ Ok ( ( ) )
2062
+ } )
2057
2063
}
2058
2064
2059
2065
fn item_static (
0 commit comments