@@ -65,7 +65,7 @@ use crate::docfs::{DocFS, ErrorStorage, PathError};
6565use crate :: doctree;
6666use crate :: fold:: DocFolder ;
6767use crate :: html:: escape:: Escape ;
68- use crate :: html:: format:: { Buffer , AsyncSpace , ConstnessSpace } ;
68+ use crate :: html:: format:: { AsyncSpace , ConstnessSpace } ;
6969use crate :: html:: format:: { GenericBounds , WhereClause , href, AbiSpace , DefaultSpace } ;
7070use crate :: html:: format:: { VisSpace , Function , UnsafetySpace , MutableSpace } ;
7171use crate :: html:: format:: fmt_impl_for_trait_page;
@@ -1185,13 +1185,12 @@ themePicker.onblur = handleThemeButtonsBlur;
11851185 SlashChecker ( s) , s)
11861186 } )
11871187 . collect:: <String >( ) ) ;
1188- let mut v = Buffer :: html ( ) ;
1189- layout:: render ( & mut v, & cx. shared . layout ,
1188+ let v = layout:: render ( & cx. shared . layout ,
11901189 & page, & ( "" ) , & content,
11911190 cx. shared . css_file_extension . is_some ( ) ,
11921191 & cx. shared . themes ,
11931192 cx. shared . generate_search_filter ) ;
1194- cx. shared . fs . write ( & dst, v. into_inner ( ) . as_bytes ( ) ) ?;
1193+ cx. shared . fs . write ( & dst, v. as_bytes ( ) ) ?;
11951194 }
11961195 }
11971196
@@ -1939,13 +1938,12 @@ impl Context {
19391938 } else {
19401939 String :: new ( )
19411940 } ;
1942- let mut v = Buffer :: html ( ) ;
1943- layout:: render ( & mut v, & self . shared . layout ,
1941+ let v = layout:: render ( & self . shared . layout ,
19441942 & page, & sidebar, & all,
19451943 self . shared . css_file_extension . is_some ( ) ,
19461944 & self . shared . themes ,
19471945 self . shared . generate_search_filter ) ;
1948- self . shared . fs . write ( & final_file, v. into_inner ( ) . as_bytes ( ) ) ?;
1946+ self . shared . fs . write ( & final_file, v. as_bytes ( ) ) ?;
19491947
19501948 // Generating settings page.
19511949 let settings = Settings :: new ( self . shared . static_root_path . as_deref ( ) . unwrap_or ( "./" ) ,
@@ -1958,24 +1956,21 @@ impl Context {
19581956 let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'></div>" ;
19591957 themes. push ( PathBuf :: from ( "settings.css" ) ) ;
19601958 let layout = self . shared . layout . clone ( ) ;
1961- let mut v = Buffer :: html ( ) ;
1962- layout:: render (
1963- & mut v,
1959+ let v = layout:: render (
19641960 & layout,
19651961 & page, & sidebar, & settings,
19661962 self . shared . css_file_extension . is_some ( ) ,
19671963 & themes,
19681964 self . shared . generate_search_filter ,
19691965 ) ;
1970- self . shared . fs . write ( & settings_file, v. into_inner ( ) . as_bytes ( ) ) ?;
1966+ self . shared . fs . write ( & settings_file, v. as_bytes ( ) ) ?;
19711967
19721968 Ok ( ( ) )
19731969 }
19741970
19751971 fn render_item ( & self ,
1976- writer : & mut Buffer ,
19771972 it : & clean:: Item ,
1978- pushname : bool ) {
1973+ pushname : bool ) -> String {
19791974 // A little unfortunate that this is done like this, but it sure
19801975 // does make formatting *a lot* nicer.
19811976 CURRENT_DEPTH . with ( |slot| {
@@ -2022,12 +2017,12 @@ impl Context {
20222017 }
20232018
20242019 if !self . render_redirect_pages {
2025- layout:: render ( writer , & self . shared . layout , & page,
2020+ layout:: render ( & self . shared . layout , & page,
20262021 & Sidebar { cx : self , item : it } ,
20272022 & Item { cx : self , item : it } ,
20282023 self . shared . css_file_extension . is_some ( ) ,
20292024 & self . shared . themes ,
2030- self . shared . generate_search_filter ) ;
2025+ self . shared . generate_search_filter )
20312026 } else {
20322027 let mut url = self . root_path ( ) ;
20332028 if let Some ( & ( ref names, ty) ) = cache ( ) . paths . get ( & it. def_id ) {
@@ -2036,7 +2031,9 @@ impl Context {
20362031 url. push_str ( "/" ) ;
20372032 }
20382033 url. push_str ( & item_path ( ty, names. last ( ) . unwrap ( ) ) ) ;
2039- layout:: redirect ( writer, & url) ;
2034+ layout:: redirect ( & url)
2035+ } else {
2036+ String :: new ( )
20402037 }
20412038 }
20422039 }
@@ -2074,13 +2071,12 @@ impl Context {
20742071
20752072 info ! ( "Recursing into {}" , self . dst. display( ) ) ;
20762073
2077- let mut buf = Buffer :: html ( ) ;
2078- self . render_item ( & mut buf, & item, false ) ;
2074+ let buf = self . render_item ( & item, false ) ;
20792075 // buf will be empty if the module is stripped and there is no redirect for it
20802076 if !buf. is_empty ( ) {
20812077 self . shared . ensure_dir ( & self . dst ) ?;
20822078 let joint_dst = self . dst . join ( "index.html" ) ;
2083- scx. fs . write ( & joint_dst, buf. into_inner ( ) . as_bytes ( ) ) ?;
2079+ scx. fs . write ( & joint_dst, buf. as_bytes ( ) ) ?;
20842080 }
20852081
20862082 let m = match item. inner {
@@ -2109,16 +2105,15 @@ impl Context {
21092105 self . dst = prev;
21102106 self . current . pop ( ) . unwrap ( ) ;
21112107 } else if item. name . is_some ( ) {
2112- let mut buf = Buffer :: html ( ) ;
2113- self . render_item ( & mut buf, & item, true ) ;
2108+ let buf = self . render_item ( & item, true ) ;
21142109 // buf will be empty if the item is stripped and there is no redirect for it
21152110 if !buf. is_empty ( ) {
21162111 let name = item. name . as_ref ( ) . unwrap ( ) ;
21172112 let item_type = item. type_ ( ) ;
21182113 let file_name = & item_path ( item_type, name) ;
21192114 self . shared . ensure_dir ( & self . dst ) ?;
21202115 let joint_dst = self . dst . join ( file_name) ;
2121- self . shared . fs . write ( & joint_dst, buf. into_inner ( ) . as_bytes ( ) ) ?;
2116+ self . shared . fs . write ( & joint_dst, buf. as_bytes ( ) ) ?;
21222117
21232118 if !self . render_redirect_pages {
21242119 all. append ( full_path ( self , & item) , & item_type) ;
@@ -2128,18 +2123,16 @@ impl Context {
21282123 // URL for the page.
21292124 let redir_name = format ! ( "{}.{}.html" , name, item_type. name_space( ) ) ;
21302125 let redir_dst = self . dst . join ( redir_name) ;
2131- let mut v = Buffer :: html ( ) ;
2132- layout:: redirect ( & mut v, file_name) ;
2133- self . shared . fs . write ( & redir_dst, v. into_inner ( ) . as_bytes ( ) ) ?;
2126+ let v = layout:: redirect ( file_name) ;
2127+ self . shared . fs . write ( & redir_dst, v. as_bytes ( ) ) ?;
21342128 }
21352129 // If the item is a macro, redirect from the old macro URL (with !)
21362130 // to the new one (without).
21372131 if item_type == ItemType :: Macro {
21382132 let redir_name = format ! ( "{}.{}!.html" , item_type, name) ;
21392133 let redir_dst = self . dst . join ( redir_name) ;
2140- let mut v = Buffer :: html ( ) ;
2141- layout:: redirect ( & mut v, file_name) ;
2142- self . shared . fs . write ( & redir_dst, v. into_inner ( ) . as_bytes ( ) ) ?;
2134+ let v = layout:: redirect ( file_name) ;
2135+ self . shared . fs . write ( & redir_dst, v. as_bytes ( ) ) ?;
21432136 }
21442137 }
21452138 }
0 commit comments