@@ -432,37 +432,22 @@ fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
432
432
format ! ( "{}{}" , to_string( |s| s. print_visibility( vis) ) , s)
433
433
}
434
434
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
457
439
}
440
+ }
458
441
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
461
445
}
446
+ }
462
447
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 > > ;
466
451
467
452
fn commasep < T , F > ( & mut self , b : Breaks , elts : & [ T ] , mut op : F )
468
453
where F : FnMut ( & mut Self , & T ) ,
@@ -728,12 +713,6 @@ pub trait PrintState<'a> {
728
713
}
729
714
self . end ( ) ;
730
715
}
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 ( " " ) }
737
716
}
738
717
739
718
impl < ' a > PrintState < ' a > for State < ' a > {
@@ -747,15 +726,6 @@ impl<'a> PrintState<'a> for State<'a> {
747
726
}
748
727
749
728
impl < ' 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
-
759
729
crate fn head < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
760
730
let w = w. into ( ) ;
761
731
// outer-box is consistent
0 commit comments