@@ -1598,6 +1598,13 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1598
1598
should_render_fields : bool ,
1599
1599
}
1600
1600
1601
+ struct Field < ' a > {
1602
+ item : & ' a clean:: Item ,
1603
+ name : String ,
1604
+ id : String ,
1605
+ ty : String ,
1606
+ }
1607
+
1601
1608
impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
1602
1609
fn new (
1603
1610
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
1642
1649
} )
1643
1650
}
1644
1651
1645
- fn render_field_in_span < ' b > (
1652
+ fn struct_field_items_iter < ' b > (
1646
1653
& ' 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) ) | {
1652
1656
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 }
1665
1662
} )
1666
1663
}
1667
1664
0 commit comments