@@ -1820,6 +1820,13 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
18201820 should_render_fields : bool ,
18211821 }
18221822
1823+ struct Field < ' a > {
1824+ item : & ' a clean:: Item ,
1825+ name : String ,
1826+ id : String ,
1827+ ty : String ,
1828+ }
1829+
18231830 impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
18241831 fn new (
18251832 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
18641871 } )
18651872 }
18661873
1867- fn render_field_in_span < ' b > (
1874+ fn struct_field_items_iter < ' b > (
18681875 & ' 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) ) | {
18741878 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 }
18871884 } )
18881885 }
18891886
0 commit comments