File tree 3 files changed +6
-28
lines changed
3 files changed +6
-28
lines changed Original file line number Diff line number Diff line change 1
- use std:: fmt:: { self , Display } ;
1
+ use std:: fmt:: Display ;
2
2
use std:: path:: PathBuf ;
3
3
4
4
use askama:: Template ;
@@ -71,23 +71,6 @@ struct PageLayout<'a> {
71
71
72
72
pub ( crate ) use crate :: html:: render:: sidebar:: filters;
73
73
74
- /// Implements [`Display`] for a function that accepts a mutable reference to a [`String`], and (optionally) writes to it.
75
- ///
76
- /// The wrapped function will receive an empty string, and can modify it,
77
- /// and the `Display` implementation will write the contents of the string after the function has finished.
78
- pub ( crate ) struct BufDisplay < F > ( pub F ) ;
79
-
80
- impl < F > Display for BufDisplay < F >
81
- where
82
- F : Fn ( & mut String ) ,
83
- {
84
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
85
- let mut buf = String :: new ( ) ;
86
- self . 0 ( & mut buf) ;
87
- f. write_str ( & buf)
88
- }
89
- }
90
-
91
74
pub ( crate ) fn render < T : Display , S : Display > (
92
75
layout : & Layout ,
93
76
page : & Page < ' _ > ,
Original file line number Diff line number Diff line change @@ -28,11 +28,10 @@ use crate::formats::cache::Cache;
28
28
use crate :: formats:: item_type:: ItemType ;
29
29
use crate :: html:: escape:: Escape ;
30
30
use crate :: html:: format:: join_with_double_colon;
31
- use crate :: html:: layout:: { self , BufDisplay } ;
32
31
use crate :: html:: markdown:: { self , ErrorCodes , IdMap , plain_text_summary} ;
33
32
use crate :: html:: render:: write_shared:: write_shared;
34
33
use crate :: html:: url_parts_builder:: UrlPartsBuilder ;
35
- use crate :: html:: { sources, static_files} ;
34
+ use crate :: html:: { layout , sources, static_files} ;
36
35
use crate :: scrape_examples:: AllCallLocations ;
37
36
use crate :: { DOC_RUST_LANG_ORG_VERSION , try_err} ;
38
37
@@ -250,9 +249,7 @@ impl<'tcx> Context<'tcx> {
250
249
layout:: render (
251
250
& self . shared . layout ,
252
251
& page,
253
- BufDisplay ( |buf : & mut String | {
254
- print_sidebar ( self , it, buf) . unwrap ( ) ;
255
- } ) ,
252
+ fmt:: from_fn ( |f| print_sidebar ( self , it, f) ) ,
256
253
content,
257
254
& self . shared . style_files ,
258
255
)
Original file line number Diff line number Diff line change @@ -11,9 +11,8 @@ use rustc_session::Session;
11
11
use rustc_span:: { FileName , FileNameDisplayPreference , RealFileName , sym} ;
12
12
use tracing:: info;
13
13
14
- use super :: highlight;
15
- use super :: layout:: { self , BufDisplay } ;
16
14
use super :: render:: Context ;
15
+ use super :: { highlight, layout} ;
17
16
use crate :: clean;
18
17
use crate :: clean:: utils:: has_doc_flag;
19
18
use crate :: docfs:: PathError ;
@@ -243,17 +242,16 @@ impl SourceCollector<'_, '_> {
243
242
& shared. layout ,
244
243
& page,
245
244
"" ,
246
- BufDisplay ( | buf : & mut String | {
245
+ fmt :: from_fn ( |f | {
247
246
print_src (
248
- buf ,
247
+ f ,
249
248
contents,
250
249
file_span,
251
250
self . cx ,
252
251
& root_path,
253
252
& highlight:: DecorationInfo :: default ( ) ,
254
253
& source_context,
255
254
)
256
- . unwrap ( ) ;
257
255
} ) ,
258
256
& shared. style_files ,
259
257
) ;
You can’t perform that action at this time.
0 commit comments