@@ -1598,6 +1598,13 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
15981598 should_render_fields : bool ,
15991599 }
16001600
1601+ struct Field < ' a > {
1602+ item : & ' a clean:: Item ,
1603+ name : String ,
1604+ id : String ,
1605+ ty : String ,
1606+ }
1607+
16011608 impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
16021609 fn new (
16031610 cx : std:: cell:: RefCell < & ' a mut Context < ' cx > > ,
@@ -1642,26 +1649,16 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
16421649 } )
16431650 }
16441651
1645- fn render_field_in_span < ' b > (
1652+ fn struct_field_items_iter < ' b > (
16461653 & ' b self ,
1647- index : & ' b usize ,
1648- field : & ' b clean:: Item ,
1649- ty : & ' b clean:: Type ,
1650- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1651- display_fn ( move |f| {
1654+ ) -> impl Iterator < Item = Field < ' a > > + Captures < ' a > + ' b + Captures < ' cx > {
1655+ struct_field_items ( self . s ) . enumerate ( ) . map ( |( index, ( item, ty) ) | {
16521656 let mut cx = self . cx . borrow_mut ( ) ;
1653- let field_name =
1654- field. name . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
1655- let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: StructField , field_name) ) ;
1656- let ty = ty. print ( * cx) ;
1657- write ! (
1658- f,
1659- "<span id=\" {id}\" class=\" {item_type} small-section-header\" >\
1660- <a href=\" #{id}\" class=\" anchor field\" >§</a>\
1661- <code>{field_name}: {ty}</code>\
1662- </span>",
1663- item_type = ItemType :: StructField ,
1664- )
1657+ let name =
1658+ item. name . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
1659+ let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: StructField , name) ) ;
1660+ let ty = ty. print ( * cx) . to_string ( ) ;
1661+ Field { item, name, id, ty }
16651662 } )
16661663 }
16671664
0 commit comments