File tree Expand file tree Collapse file tree 3 files changed +6
-28
lines changed Expand file tree Collapse file tree 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 ;
22use std:: path:: PathBuf ;
33
44use askama:: Template ;
@@ -71,23 +71,6 @@ struct PageLayout<'a> {
7171
7272pub ( crate ) use crate :: html:: render:: sidebar:: filters;
7373
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-
9174pub ( crate ) fn render < T : Display , S : Display > (
9275 layout : & Layout ,
9376 page : & Page < ' _ > ,
Original file line number Diff line number Diff line change @@ -28,11 +28,10 @@ use crate::formats::cache::Cache;
2828use crate :: formats:: item_type:: ItemType ;
2929use crate :: html:: escape:: Escape ;
3030use crate :: html:: format:: join_with_double_colon;
31- use crate :: html:: layout:: { self , BufDisplay } ;
3231use crate :: html:: markdown:: { self , ErrorCodes , IdMap , plain_text_summary} ;
3332use crate :: html:: render:: write_shared:: write_shared;
3433use crate :: html:: url_parts_builder:: UrlPartsBuilder ;
35- use crate :: html:: { sources, static_files} ;
34+ use crate :: html:: { layout , sources, static_files} ;
3635use crate :: scrape_examples:: AllCallLocations ;
3736use crate :: { DOC_RUST_LANG_ORG_VERSION , try_err} ;
3837
@@ -250,9 +249,7 @@ impl<'tcx> Context<'tcx> {
250249 layout:: render (
251250 & self . shared . layout ,
252251 & page,
253- BufDisplay ( |buf : & mut String | {
254- print_sidebar ( self , it, buf) . unwrap ( ) ;
255- } ) ,
252+ fmt:: from_fn ( |f| print_sidebar ( self , it, f) ) ,
256253 content,
257254 & self . shared . style_files ,
258255 )
Original file line number Diff line number Diff line change @@ -11,9 +11,8 @@ use rustc_session::Session;
1111use rustc_span:: { FileName , FileNameDisplayPreference , RealFileName , sym} ;
1212use tracing:: info;
1313
14- use super :: highlight;
15- use super :: layout:: { self , BufDisplay } ;
1614use super :: render:: Context ;
15+ use super :: { highlight, layout} ;
1716use crate :: clean;
1817use crate :: clean:: utils:: has_doc_flag;
1918use crate :: docfs:: PathError ;
@@ -243,17 +242,16 @@ impl SourceCollector<'_, '_> {
243242 & shared. layout ,
244243 & page,
245244 "" ,
246- BufDisplay ( | buf : & mut String | {
245+ fmt :: from_fn ( |f | {
247246 print_src (
248- buf ,
247+ f ,
249248 contents,
250249 file_span,
251250 self . cx ,
252251 & root_path,
253252 & highlight:: DecorationInfo :: default ( ) ,
254253 & source_context,
255254 )
256- . unwrap ( ) ;
257255 } ) ,
258256 & shared. style_files ,
259257 ) ;
You can’t perform that action at this time.
0 commit comments