@@ -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:: { Print , Buffer , 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;
@@ -4266,15 +4266,15 @@ fn item_foreign_type(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item)
42664266 render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
42674267}
42684268
4269- impl < ' a > fmt :: Display for Sidebar < ' a > {
4270- fn fmt ( & self , fmt : & mut fmt :: Formatter < ' _ > ) -> fmt :: Result {
4269+ impl Print for Sidebar < ' _ > {
4270+ fn print ( & self , buffer : & mut Buffer ) {
42714271 let cx = self . cx ;
42724272 let it = self . item ;
42734273 let parentlen = cx. current . len ( ) - if it. is_mod ( ) { 1 } else { 0 } ;
42744274
42754275 if it. is_struct ( ) || it. is_trait ( ) || it. is_primitive ( ) || it. is_union ( )
42764276 || it. is_enum ( ) || it. is_mod ( ) || it. is_typedef ( ) {
4277- write ! ( fmt , "<p class='location'>{}{}</p>" ,
4277+ write ! ( buffer , "<p class='location'>{}{}</p>" ,
42784278 match it. inner {
42794279 clean:: StructItem ( ..) => "Struct " ,
42804280 clean:: TraitItem ( ..) => "Trait " ,
@@ -4290,33 +4290,33 @@ impl<'a> fmt::Display for Sidebar<'a> {
42904290 } ,
42914291 _ => "" ,
42924292 } ,
4293- it. name. as_ref( ) . unwrap( ) ) ? ;
4293+ it. name. as_ref( ) . unwrap( ) ) ;
42944294 }
42954295
42964296 if it. is_crate ( ) {
42974297 if let Some ( ref version) = cache ( ) . crate_version {
4298- write ! ( fmt ,
4298+ write ! ( buffer ,
42994299 "<div class='block version'>\
43004300 <p>Version {}</p>\
43014301 </div>",
4302- version) ? ;
4302+ version) ;
43034303 }
43044304 }
43054305
4306- write ! ( fmt , "<div class=\" sidebar-elems\" >" ) ? ;
4306+ write ! ( buffer , "<div class=\" sidebar-elems\" >" ) ;
43074307 if it. is_crate ( ) {
4308- write ! ( fmt , "<a id='all-types' href='all.html'><p>See all {}'s items</p></a>" ,
4309- it. name. as_ref( ) . expect( "crates always have a name" ) ) ? ;
4308+ write ! ( buffer , "<a id='all-types' href='all.html'><p>See all {}'s items</p></a>" ,
4309+ it. name. as_ref( ) . expect( "crates always have a name" ) ) ;
43104310 }
43114311 match it. inner {
4312- clean:: StructItem ( ref s) => sidebar_struct ( fmt , it, s) ? ,
4313- clean:: TraitItem ( ref t) => sidebar_trait ( fmt , it, t) ? ,
4314- clean:: PrimitiveItem ( ref p) => sidebar_primitive ( fmt , it, p) ? ,
4315- clean:: UnionItem ( ref u) => sidebar_union ( fmt , it, u) ? ,
4316- clean:: EnumItem ( ref e) => sidebar_enum ( fmt , it, e) ? ,
4317- clean:: TypedefItem ( ref t, _) => sidebar_typedef ( fmt , it, t) ? ,
4318- clean:: ModuleItem ( ref m) => sidebar_module ( fmt , it, & m. items ) ? ,
4319- clean:: ForeignTypeItem => sidebar_foreign_type ( fmt , it) ? ,
4312+ clean:: StructItem ( ref s) => sidebar_struct ( buffer , it, s) ,
4313+ clean:: TraitItem ( ref t) => sidebar_trait ( buffer , it, t) ,
4314+ clean:: PrimitiveItem ( ref p) => sidebar_primitive ( buffer , it, p) ,
4315+ clean:: UnionItem ( ref u) => sidebar_union ( buffer , it, u) ,
4316+ clean:: EnumItem ( ref e) => sidebar_enum ( buffer , it, e) ,
4317+ clean:: TypedefItem ( ref t, _) => sidebar_typedef ( buffer , it, t) ,
4318+ clean:: ModuleItem ( ref m) => sidebar_module ( buffer , it, & m. items ) ,
4319+ clean:: ForeignTypeItem => sidebar_foreign_type ( buffer , it) ,
43204320 _ => ( ) ,
43214321 }
43224322
@@ -4328,39 +4328,37 @@ impl<'a> fmt::Display for Sidebar<'a> {
43284328 // as much HTML as possible in order to allow non-JS-enabled browsers
43294329 // to navigate the documentation (though slightly inefficiently).
43304330
4331- write ! ( fmt , "<p class='location'>" ) ? ;
4331+ write ! ( buffer , "<p class='location'>" ) ;
43324332 for ( i, name) in cx. current . iter ( ) . take ( parentlen) . enumerate ( ) {
43334333 if i > 0 {
4334- write ! ( fmt , "::<wbr>" ) ? ;
4334+ write ! ( buffer , "::<wbr>" ) ;
43354335 }
4336- write ! ( fmt , "<a href='{}index.html'>{}</a>" ,
4336+ write ! ( buffer , "<a href='{}index.html'>{}</a>" ,
43374337 & cx. root_path( ) [ ..( cx. current. len( ) - i - 1 ) * 3 ] ,
4338- * name) ? ;
4338+ * name) ;
43394339 }
4340- write ! ( fmt , "</p>" ) ? ;
4340+ write ! ( buffer , "</p>" ) ;
43414341
43424342 // Sidebar refers to the enclosing module, not this module.
43434343 let relpath = if it. is_mod ( ) { "../" } else { "" } ;
4344- write ! ( fmt ,
4344+ write ! ( buffer ,
43454345 "<script>window.sidebarCurrent = {{\
43464346 name: '{name}', \
43474347 ty: '{ty}', \
43484348 relpath: '{path}'\
43494349 }};</script>",
43504350 name = it. name. as_ref( ) . map( |x| & x[ ..] ) . unwrap_or( "" ) ,
43514351 ty = it. type_( ) . css_class( ) ,
4352- path = relpath) ? ;
4352+ path = relpath) ;
43534353 if parentlen == 0 {
43544354 // There is no sidebar-items.js beyond the crate root path
43554355 // FIXME maybe dynamic crate loading can be merged here
43564356 } else {
4357- write ! ( fmt , "<script defer src=\" {path}sidebar-items.js\" ></script>" ,
4358- path = relpath) ? ;
4357+ write ! ( buffer , "<script defer src=\" {path}sidebar-items.js\" ></script>" ,
4358+ path = relpath) ;
43594359 }
43604360 // Closes sidebar-elems div.
4361- write ! ( fmt, "</div>" ) ?;
4362-
4363- Ok ( ( ) )
4361+ write ! ( buffer, "</div>" ) ;
43644362 }
43654363}
43664364
@@ -4534,8 +4532,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
45344532 out
45354533}
45364534
4537- fn sidebar_struct ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4538- s : & clean:: Struct ) -> fmt:: Result {
4535+ fn sidebar_struct ( buf : & mut Buffer , it : & clean:: Item , s : & clean:: Struct ) {
45394536 let mut sidebar = String :: new ( ) ;
45404537 let fields = get_struct_fields_name ( & s. fields ) ;
45414538
@@ -4549,9 +4546,8 @@ fn sidebar_struct(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
45494546 sidebar. push_str ( & sidebar_assoc_items ( it) ) ;
45504547
45514548 if !sidebar. is_empty ( ) {
4552- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4549+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
45534550 }
4554- Ok ( ( ) )
45554551}
45564552
45574553fn get_id_for_impl_on_foreign_type ( for_ : & clean:: Type , trait_ : & clean:: Type ) -> String {
@@ -4575,8 +4571,7 @@ fn is_negative_impl(i: &clean::Impl) -> bool {
45754571 i. polarity == Some ( clean:: ImplPolarity :: Negative )
45764572}
45774573
4578- fn sidebar_trait ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4579- t : & clean:: Trait ) -> fmt:: Result {
4574+ fn sidebar_trait ( buf : & mut Buffer , it : & clean:: Item , t : & clean:: Trait ) {
45804575 let mut sidebar = String :: new ( ) ;
45814576
45824577 let types = t. items
@@ -4684,27 +4679,23 @@ fn sidebar_trait(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
46844679
46854680 sidebar. push_str ( & sidebar_assoc_items ( it) ) ;
46864681
4687- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar)
4682+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar)
46884683}
46894684
4690- fn sidebar_primitive ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4691- _p : & clean:: PrimitiveType ) -> fmt:: Result {
4685+ fn sidebar_primitive ( buf : & mut Buffer , it : & clean:: Item , _p : & clean:: PrimitiveType ) {
46924686 let sidebar = sidebar_assoc_items ( it) ;
46934687
46944688 if !sidebar. is_empty ( ) {
4695- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4689+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
46964690 }
4697- Ok ( ( ) )
46984691}
46994692
4700- fn sidebar_typedef ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4701- _t : & clean:: Typedef ) -> fmt:: Result {
4693+ fn sidebar_typedef ( buf : & mut Buffer , it : & clean:: Item , _t : & clean:: Typedef ) {
47024694 let sidebar = sidebar_assoc_items ( it) ;
47034695
47044696 if !sidebar. is_empty ( ) {
4705- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4697+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
47064698 }
4707- Ok ( ( ) )
47084699}
47094700
47104701fn get_struct_fields_name ( fields : & [ clean:: Item ] ) -> String {
@@ -4722,8 +4713,7 @@ fn get_struct_fields_name(fields: &[clean::Item]) -> String {
47224713 . collect ( )
47234714}
47244715
4725- fn sidebar_union ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4726- u : & clean:: Union ) -> fmt:: Result {
4716+ fn sidebar_union ( buf : & mut Buffer , it : & clean:: Item , u : & clean:: Union ) {
47274717 let mut sidebar = String :: new ( ) ;
47284718 let fields = get_struct_fields_name ( & u. fields ) ;
47294719
@@ -4735,13 +4725,11 @@ fn sidebar_union(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
47354725 sidebar. push_str ( & sidebar_assoc_items ( it) ) ;
47364726
47374727 if !sidebar. is_empty ( ) {
4738- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4728+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
47394729 }
4740- Ok ( ( ) )
47414730}
47424731
4743- fn sidebar_enum ( fmt : & mut fmt:: Formatter < ' _ > , it : & clean:: Item ,
4744- e : & clean:: Enum ) -> fmt:: Result {
4732+ fn sidebar_enum ( buf : & mut Buffer , it : & clean:: Item , e : & clean:: Enum ) {
47454733 let mut sidebar = String :: new ( ) ;
47464734
47474735 let variants = e. variants . iter ( )
@@ -4759,9 +4747,8 @@ fn sidebar_enum(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
47594747 sidebar. push_str ( & sidebar_assoc_items ( it) ) ;
47604748
47614749 if !sidebar. is_empty ( ) {
4762- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4750+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
47634751 }
4764- Ok ( ( ) )
47654752}
47664753
47674754fn item_ty_to_strs ( ty : & ItemType ) -> ( & ' static str , & ' static str ) {
@@ -4795,8 +4782,7 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
47954782 }
47964783}
47974784
4798- fn sidebar_module ( fmt : & mut fmt:: Formatter < ' _ > , _it : & clean:: Item ,
4799- items : & [ clean:: Item ] ) -> fmt:: Result {
4785+ fn sidebar_module ( buf : & mut Buffer , _it : & clean:: Item , items : & [ clean:: Item ] ) {
48004786 let mut sidebar = String :: new ( ) ;
48014787
48024788 if items. iter ( ) . any ( |it| it. type_ ( ) == ItemType :: ExternCrate ||
@@ -4823,17 +4809,15 @@ fn sidebar_module(fmt: &mut fmt::Formatter<'_>, _it: &clean::Item,
48234809 }
48244810
48254811 if !sidebar. is_empty ( ) {
4826- write ! ( fmt , "<div class=\" block items\" ><ul>{}</ul></div>" , sidebar) ? ;
4812+ write ! ( buf , "<div class=\" block items\" ><ul>{}</ul></div>" , sidebar) ;
48274813 }
4828- Ok ( ( ) )
48294814}
48304815
4831- fn sidebar_foreign_type ( fmt : & mut fmt :: Formatter < ' _ > , it : & clean:: Item ) -> fmt :: Result {
4816+ fn sidebar_foreign_type ( buf : & mut Buffer , it : & clean:: Item ) {
48324817 let sidebar = sidebar_assoc_items ( it) ;
48334818 if !sidebar. is_empty ( ) {
4834- write ! ( fmt , "<div class=\" block items\" >{}</div>" , sidebar) ? ;
4819+ write ! ( buf , "<div class=\" block items\" >{}</div>" , sidebar) ;
48354820 }
4836- Ok ( ( ) )
48374821}
48384822
48394823fn item_macro ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ,
0 commit comments