@@ -325,6 +325,59 @@ trait ItemTemplate<'a, 'cx: 'a>: askama::Template + fmt::Display {
325
325
fn item_and_mut_cx ( & self ) -> ( & ' a clean:: Item , RefMut < ' _ , & ' a mut Context < ' cx > > ) ;
326
326
}
327
327
328
+ fn item_template_document < ' a : ' b , ' b , ' cx : ' a > (
329
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
330
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
331
+ display_fn ( move |f| {
332
+ let ( item, mut cx) = templ. item_and_mut_cx ( ) ;
333
+ let v = document ( * cx, item, None , HeadingOffset :: H2 ) ;
334
+ write ! ( f, "{v}" )
335
+ } )
336
+ }
337
+
338
+ fn item_template_document_type_layout < ' a : ' b , ' b , ' cx : ' a > (
339
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
340
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
341
+ display_fn ( move |f| {
342
+ let ( item, cx) = templ. item_and_mut_cx ( ) ;
343
+ let def_id = item. item_id . expect_def_id ( ) ;
344
+ let v = document_type_layout ( * cx, def_id) ;
345
+ write ! ( f, "{v}" )
346
+ } )
347
+ }
348
+
349
+ fn item_template_render_attributes_in_pre < ' a : ' b , ' b , ' cx : ' a > (
350
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
351
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
352
+ display_fn ( move |f| {
353
+ let ( item, cx) = templ. item_and_mut_cx ( ) ;
354
+ let tcx = cx. tcx ( ) ;
355
+ let v = render_attributes_in_pre ( item, "" , tcx) ;
356
+ write ! ( f, "{v}" )
357
+ } )
358
+ }
359
+
360
+ fn item_template_render_attributes_in_code < ' a : ' b , ' b , ' cx : ' a > (
361
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
362
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
363
+ display_fn ( move |f| {
364
+ let ( it, cx) = templ. item_and_mut_cx ( ) ;
365
+ let v = render_attributes_in_code ( it, cx. tcx ( ) ) ;
366
+ write ! ( f, "{v}" )
367
+ } )
368
+ }
369
+
370
+ fn item_template_render_assoc_items < ' a : ' b , ' b , ' cx : ' a > (
371
+ templ : & ' b impl ItemTemplate < ' a , ' cx > ,
372
+ ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
373
+ display_fn ( move |f| {
374
+ let ( item, mut cx) = templ. item_and_mut_cx ( ) ;
375
+ let def_id = item. item_id . expect_def_id ( ) ;
376
+ let v = render_assoc_items ( * cx, item, def_id, AssocItemRender :: All , None ) ;
377
+ write ! ( f, "{v}" )
378
+ } )
379
+ }
380
+
328
381
fn item_module ( w : & mut Buffer , cx : & mut Context < ' _ > , item : & clean:: Item , items : & [ clean:: Item ] ) {
329
382
write ! ( w, "{}" , document( cx, item, None , HeadingOffset :: H2 ) ) ;
330
383
@@ -1605,6 +1658,12 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1605
1658
ty : String ,
1606
1659
}
1607
1660
1661
+ impl < ' a , ' cx : ' a > ItemTemplate < ' a , ' cx > for ItemStruct < ' a , ' cx > {
1662
+ fn item_and_mut_cx ( & self ) -> ( & ' a clean:: Item , RefMut < ' _ , & ' a mut Context < ' cx > > ) {
1663
+ ( self . it , self . cx . borrow_mut ( ) )
1664
+ }
1665
+ }
1666
+
1608
1667
impl < ' a , ' cx : ' a > ItemStruct < ' a , ' cx > {
1609
1668
fn new (
1610
1669
cx : std:: cell:: RefCell < & ' a mut Context < ' cx > > ,
@@ -1616,15 +1675,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1616
1675
Self { cx, it, s, should_render_fields }
1617
1676
}
1618
1677
1619
- fn render_attributes_in_code < ' b > (
1620
- & ' b self ,
1621
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1622
- display_fn ( move |f| {
1623
- let tcx = self . cx . borrow ( ) . tcx ( ) ;
1624
- write ! ( f, "{}" , render_attributes_in_code( self . it, tcx) )
1625
- } )
1626
- }
1627
-
1628
1678
fn render_struct < ' b > ( & ' b self ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1629
1679
display_fn ( move |f| {
1630
1680
let cx = self . cx . borrow ( ) ;
@@ -1641,14 +1691,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1641
1691
} )
1642
1692
}
1643
1693
1644
- fn document < ' b > ( & ' b self ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1645
- display_fn ( move |f| {
1646
- let mut cx = self . cx . borrow_mut ( ) ;
1647
- let v = document ( * cx, self . it , None , HeadingOffset :: H2 ) ;
1648
- write ! ( f, "{v}" )
1649
- } )
1650
- }
1651
-
1652
1694
fn struct_field_items_iter < ' b > (
1653
1695
& ' b self ,
1654
1696
) -> impl Iterator < Item = Field < ' a > > + Captures < ' a > + ' b + Captures < ' cx > {
@@ -1672,28 +1714,6 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
1672
1714
write ! ( f, "{v}" )
1673
1715
} )
1674
1716
}
1675
-
1676
- fn render_assoc_items < ' b > (
1677
- & ' b self ,
1678
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1679
- display_fn ( move |f| {
1680
- let mut cx = self . cx . borrow_mut ( ) ;
1681
- let def_id = self . it . item_id . expect_def_id ( ) ;
1682
- let v = render_assoc_items ( * cx, self . it , def_id, AssocItemRender :: All ) ;
1683
- write ! ( f, "{v}" )
1684
- } )
1685
- }
1686
-
1687
- fn document_type_layout < ' b > (
1688
- & ' b self ,
1689
- ) -> impl fmt:: Display + Captures < ' a > + ' b + Captures < ' cx > {
1690
- display_fn ( move |f| {
1691
- let cx = self . cx . borrow ( ) ;
1692
- let def_id = self . it . item_id . expect_def_id ( ) ;
1693
- let v = document_type_layout ( * cx, def_id) ;
1694
- write ! ( f, "{v}" )
1695
- } )
1696
- }
1697
1717
}
1698
1718
1699
1719
ItemStruct :: new ( std:: cell:: RefCell :: new ( cx) , it, s) . render_into ( w) . unwrap ( ) ;
0 commit comments