@@ -1820,6 +1820,13 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1820
1820
should_render_fields : bool ,
1821
1821
}
1822
1822
1823
+ struct Field < ' a > {
1824
+ item : & ' a clean:: Item ,
1825
+ name : String ,
1826
+ id : String ,
1827
+ ty : String ,
1828
+ }
1829
+
1823
1830
impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
1824
1831
fn new (
1825
1832
cx : std:: cell:: RefCell < & ' a mut Context < ' cx > > ,
@@ -1864,26 +1871,16 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1864
1871
} )
1865
1872
}
1866
1873
1867
- fn render_field_in_span < ' b > (
1874
+ fn struct_field_items_iter < ' b > (
1868
1875
& ' b self ,
1869
- index : & ' b usize ,
1870
- field : & ' b clean:: Item ,
1871
- ty : & ' b clean:: Type ,
1872
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1873
- display_fn ( move |f| {
1876
+ ) -> impl Iterator < Item = Field < ' a > > + Captures < ' a > + ' b + Captures < ' cx > {
1877
+ struct_field_items ( self . s ) . enumerate ( ) . map ( |( index, ( item, ty) ) | {
1874
1878
let mut cx = self . cx . borrow_mut ( ) ;
1875
- let field_name =
1876
- field. name . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
1877
- let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: StructField , field_name) ) ;
1878
- let ty = ty. print ( * cx) ;
1879
- write ! (
1880
- f,
1881
- "<span id=\" {id}\" class=\" {item_type} small-section-header\" >\
1882
- <a href=\" #{id}\" class=\" anchor field\" >§</a>\
1883
- <code>{field_name}: {ty}</code>\
1884
- </span>",
1885
- item_type = ItemType :: StructField ,
1886
- )
1879
+ let name =
1880
+ item. name . map_or_else ( || index. to_string ( ) , |sym| sym. as_str ( ) . to_string ( ) ) ;
1881
+ let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: StructField , name) ) ;
1882
+ let ty = ty. print ( * cx) . to_string ( ) ;
1883
+ Field { item, name, id, ty }
1887
1884
} )
1888
1885
}
1889
1886
0 commit comments