@@ -326,6 +326,59 @@ trait ItemTemplate<'a, 'cx: 'a>: askama::Template + fmt::Display {
326
326
fn item_and_mut_cx ( & self ) -> ( & ' a clean:: Item , RefMut < ' _ , & ' a mut Context < ' cx > > ) ;
327
327
}
328
328
329
+ fn item_template_document < ' a : ' b , ' b , ' cx : ' a > (
330
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
331
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
332
+ display_fn ( move |f| {
333
+ let ( item, mut cx) = templ. item_and_mut_cx ( ) ;
334
+ let v = document ( * cx, item, None , HeadingOffset :: H2 ) ;
335
+ write ! ( f, "{v}" )
336
+ } )
337
+ }
338
+
339
+ fn item_template_document_type_layout < ' a : ' b , ' b , ' cx : ' a > (
340
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
341
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
342
+ display_fn ( move |f| {
343
+ let ( item, cx) = templ. item_and_mut_cx ( ) ;
344
+ let def_id = item. item_id . expect_def_id ( ) ;
345
+ let v = document_type_layout ( * cx, def_id) ;
346
+ write ! ( f, "{v}" )
347
+ } )
348
+ }
349
+
350
+ fn item_template_render_attributes_in_pre < ' a : ' b , ' b , ' cx : ' a > (
351
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
352
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
353
+ display_fn ( move |f| {
354
+ let ( item, cx) = templ. item_and_mut_cx ( ) ;
355
+ let tcx = cx. tcx ( ) ;
356
+ let v = render_attributes_in_pre ( item, "" , tcx) ;
357
+ write ! ( f, "{v}" )
358
+ } )
359
+ }
360
+
361
+ fn item_template_render_attributes_in_code < ' a : ' b , ' b , ' cx : ' a > (
362
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
363
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
364
+ display_fn ( move |f| {
365
+ let ( it, cx) = templ. item_and_mut_cx ( ) ;
366
+ let v = render_attributes_in_code ( it, cx. tcx ( ) ) ;
367
+ write ! ( f, "{v}" )
368
+ } )
369
+ }
370
+
371
+ fn item_template_render_assoc_items < ' a : ' b , ' b , ' cx : ' a > (
372
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
373
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
374
+ display_fn ( move |f| {
375
+ let ( item, mut cx) = templ. item_and_mut_cx ( ) ;
376
+ let def_id = item. item_id . expect_def_id ( ) ;
377
+ let v = render_assoc_items ( * cx, item, def_id, AssocItemRender :: All , None ) ;
378
+ write ! ( f, "{v}" )
379
+ } )
380
+ }
381
+
329
382
fn item_module ( w : & mut Buffer , cx : & mut Context < ' _ > , item : & clean:: Item , items : & [ clean:: Item ] ) {
330
383
write ! ( w, "{}" , document( cx, item, None , HeadingOffset :: H2 ) ) ;
331
384
@@ -1827,6 +1880,12 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1827
1880
ty : String ,
1828
1881
}
1829
1882
1883
+ impl < ' a , ' cx : ' a > ItemTemplate < ' a , ' cx > for ItemStruct < ' a , ' cx > {
1884
+ fn item_and_mut_cx ( & self ) -> ( & ' a clean:: Item , RefMut < ' _ , & ' a mut Context < ' cx > > ) {
1885
+ ( self . it , self . cx . borrow_mut ( ) )
1886
+ }
1887
+ }
1888
+
1830
1889
impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
1831
1890
fn new (
1832
1891
cx : std:: cell:: RefCell < & ' a mut Context < ' cx > > ,
@@ -1838,15 +1897,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1838
1897
Self { cx, it, s, should_render_fields }
1839
1898
}
1840
1899
1841
- fn render_attributes_in_code < ' b > (
1842
- & ' b self ,
1843
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1844
- display_fn ( move |f| {
1845
- let tcx = self . cx . borrow ( ) . tcx ( ) ;
1846
- write ! ( f, "{}" , render_attributes_in_code( self . it, tcx) )
1847
- } )
1848
- }
1849
-
1850
1900
fn render_struct < ' b > ( & ' b self ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1851
1901
display_fn ( move |f| {
1852
1902
let cx = self . cx . borrow ( ) ;
@@ -1863,14 +1913,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1863
1913
} )
1864
1914
}
1865
1915
1866
- fn document < ' b > ( & ' b self ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1867
- display_fn ( move |f| {
1868
- let mut cx = self . cx . borrow_mut ( ) ;
1869
- let v = document ( * cx, self . it , None , HeadingOffset :: H2 ) ;
1870
- write ! ( f, "{v}" )
1871
- } )
1872
- }
1873
-
1874
1916
fn struct_field_items_iter < ' b > (
1875
1917
& ' b self ,
1876
1918
) -> impl Iterator < Item = Field < ' a > > + Captures < ' a > + ' b + Captures < ' cx > {
@@ -1894,28 +1936,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1894
1936
write ! ( f, "{v}" )
1895
1937
} )
1896
1938
}
1897
-
1898
- fn render_assoc_items < ' b > (
1899
- & ' b self ,
1900
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1901
- display_fn ( move |f| {
1902
- let mut cx = self . cx . borrow_mut ( ) ;
1903
- let def_id = self . it . item_id . expect_def_id ( ) ;
1904
- let v = render_assoc_items ( * cx, self . it , def_id, AssocItemRender :: All ) ;
1905
- write ! ( f, "{v}" )
1906
- } )
1907
- }
1908
-
1909
- fn document_type_layout < ' b > (
1910
- & ' b self ,
1911
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1912
- display_fn ( move |f| {
1913
- let cx = self . cx . borrow ( ) ;
1914
- let def_id = self . it . item_id . expect_def_id ( ) ;
1915
- let v = document_type_layout ( * cx, def_id) ;
1916
- write ! ( f, "{v}" )
1917
- } )
1918
- }
1919
1939
}
1920
1940
1921
1941
ItemStruct :: new ( std:: cell:: RefCell :: new ( cx) , it, s) . render_into ( w) . unwrap ( ) ;
0 commit comments