@@ -432,37 +432,22 @@ fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
432432 format ! ( "{}{}" , to_string( |s| s. print_visibility( vis) ) , s)
433433}
434434
435- pub trait PrintState < ' a > {
436- fn writer ( & mut self ) -> & mut pp:: Printer ;
437- fn comments ( & mut self ) -> & mut Option < Comments < ' a > > ;
438-
439- fn word_space < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
440- self . writer ( ) . word ( w) ;
441- self . writer ( ) . space ( )
442- }
443-
444- fn popen ( & mut self ) { self . writer ( ) . word ( "(" ) }
445-
446- fn pclose ( & mut self ) { self . writer ( ) . word ( ")" ) }
447-
448- fn hardbreak_if_not_bol ( & mut self ) {
449- if !self . writer ( ) . is_beginning_of_line ( ) {
450- self . writer ( ) . hardbreak ( )
451- }
452- }
453-
454- // "raw box"
455- fn rbox ( & mut self , u : usize , b : pp:: Breaks ) {
456- self . writer ( ) . rbox ( u, b)
435+ impl std:: ops:: Deref for State < ' _ > {
436+ type Target = pp:: Printer ;
437+ fn deref ( & self ) -> & Self :: Target {
438+ & self . s
457439 }
440+ }
458441
459- fn ibox ( & mut self , u : usize ) {
460- self . writer ( ) . ibox ( u) ;
442+ impl std:: ops:: DerefMut for State < ' _ > {
443+ fn deref_mut ( & mut self ) -> & mut Self :: Target {
444+ & mut self . s
461445 }
446+ }
462447
463- fn end ( & mut self ) {
464- self . writer ( ) . end ( )
465- }
448+ pub trait PrintState < ' a > : std :: ops :: Deref < Target =pp :: Printer > + std :: ops :: DerefMut {
449+ fn writer ( & mut self ) -> & mut pp :: Printer ;
450+ fn comments ( & mut self ) -> & mut Option < Comments < ' a > > ;
466451
467452 fn commasep < T , F > ( & mut self , b : Breaks , elts : & [ T ] , mut op : F )
468453 where F : FnMut ( & mut Self , & T ) ,
@@ -728,12 +713,6 @@ pub trait PrintState<'a> {
728713 }
729714 self . end ( ) ;
730715 }
731-
732- fn space_if_not_bol ( & mut self ) {
733- if !self . writer ( ) . is_beginning_of_line ( ) { self . writer ( ) . space ( ) ; }
734- }
735-
736- fn nbsp ( & mut self ) { self . writer ( ) . word ( " " ) }
737716}
738717
739718impl < ' a > PrintState < ' a > for State < ' a > {
@@ -747,15 +726,6 @@ impl<'a> PrintState<'a> for State<'a> {
747726}
748727
749728impl < ' a > State < ' a > {
750- pub fn cbox ( & mut self , u : usize ) {
751- self . s . cbox ( u) ;
752- }
753-
754- crate fn word_nbsp < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
755- self . s . word ( w) ;
756- self . nbsp ( )
757- }
758-
759729 crate fn head < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
760730 let w = w. into ( ) ;
761731 // outer-box is consistent
0 commit comments