@@ -172,7 +172,7 @@ pub enum Token {
172172}
173173
174174impl Token {
175- pub fn is_eof ( & self ) -> bool {
175+ crate fn is_eof ( & self ) -> bool {
176176 match * self {
177177 Token :: Eof => true ,
178178 _ => false ,
@@ -223,13 +223,13 @@ fn buf_str(buf: &[BufEntry], left: usize, right: usize, lim: usize) -> String {
223223}
224224
225225#[ derive( Copy , Clone ) ]
226- pub enum PrintStackBreak {
226+ crate enum PrintStackBreak {
227227 Fits ,
228228 Broken ( Breaks ) ,
229229}
230230
231231#[ derive( Copy , Clone ) ]
232- pub struct PrintStackElem {
232+ crate struct PrintStackElem {
233233 offset : isize ,
234234 pbreak : PrintStackBreak
235235}
@@ -386,7 +386,7 @@ impl<'a> Printer<'a> {
386386 }
387387 }
388388
389- pub fn check_stream ( & mut self ) -> io:: Result < ( ) > {
389+ crate fn check_stream ( & mut self ) -> io:: Result < ( ) > {
390390 debug ! ( "check_stream Vec<{}, {}> with left_total={}, right_total={}" ,
391391 self . left, self . right, self . left_total, self . right_total) ;
392392 if self . right_total - self . left_total > self . space {
@@ -405,24 +405,24 @@ impl<'a> Printer<'a> {
405405 Ok ( ( ) )
406406 }
407407
408- pub fn scan_push ( & mut self , x : usize ) {
408+ crate fn scan_push ( & mut self , x : usize ) {
409409 debug ! ( "scan_push {}" , x) ;
410410 self . scan_stack . push_front ( x) ;
411411 }
412412
413- pub fn scan_pop ( & mut self ) -> usize {
413+ crate fn scan_pop ( & mut self ) -> usize {
414414 self . scan_stack . pop_front ( ) . unwrap ( )
415415 }
416416
417- pub fn scan_top ( & mut self ) -> usize {
417+ crate fn scan_top ( & mut self ) -> usize {
418418 * self . scan_stack . front ( ) . unwrap ( )
419419 }
420420
421- pub fn scan_pop_bottom ( & mut self ) -> usize {
421+ crate fn scan_pop_bottom ( & mut self ) -> usize {
422422 self . scan_stack . pop_back ( ) . unwrap ( )
423423 }
424424
425- pub fn advance_right ( & mut self ) {
425+ crate fn advance_right ( & mut self ) {
426426 self . right += 1 ;
427427 self . right %= self . buf_max_len ;
428428 // Extend the buf if necessary.
@@ -432,7 +432,7 @@ impl<'a> Printer<'a> {
432432 assert_ne ! ( self . right, self . left) ;
433433 }
434434
435- pub fn advance_left ( & mut self ) -> io:: Result < ( ) > {
435+ crate fn advance_left ( & mut self ) -> io:: Result < ( ) > {
436436 debug ! ( "advance_left Vec<{},{}>, sizeof({})={}" , self . left, self . right,
437437 self . left, self . buf[ self . left] . size) ;
438438
@@ -467,7 +467,7 @@ impl<'a> Printer<'a> {
467467 Ok ( ( ) )
468468 }
469469
470- pub fn check_stack ( & mut self , k : isize ) {
470+ crate fn check_stack ( & mut self , k : isize ) {
471471 if !self . scan_stack . is_empty ( ) {
472472 let x = self . scan_top ( ) ;
473473 match self . buf [ x] . token {
@@ -495,20 +495,20 @@ impl<'a> Printer<'a> {
495495 }
496496 }
497497
498- pub fn print_newline ( & mut self , amount : isize ) -> io:: Result < ( ) > {
498+ crate fn print_newline ( & mut self , amount : isize ) -> io:: Result < ( ) > {
499499 debug ! ( "NEWLINE {}" , amount) ;
500500 let ret = writeln ! ( self . out) ;
501501 self . pending_indentation = 0 ;
502502 self . indent ( amount) ;
503503 ret
504504 }
505505
506- pub fn indent ( & mut self , amount : isize ) {
506+ crate fn indent ( & mut self , amount : isize ) {
507507 debug ! ( "INDENT {}" , amount) ;
508508 self . pending_indentation += amount;
509509 }
510510
511- pub fn get_top ( & mut self ) -> PrintStackElem {
511+ crate fn get_top ( & mut self ) -> PrintStackElem {
512512 match self . print_stack . last ( ) {
513513 Some ( el) => * el,
514514 None => PrintStackElem {
@@ -518,7 +518,7 @@ impl<'a> Printer<'a> {
518518 }
519519 }
520520
521- pub fn print_begin ( & mut self , b : BeginToken , l : isize ) -> io:: Result < ( ) > {
521+ crate fn print_begin ( & mut self , b : BeginToken , l : isize ) -> io:: Result < ( ) > {
522522 if l > self . space {
523523 let col = self . margin - self . space + b. offset ;
524524 debug ! ( "print Begin -> push broken block at col {}" , col) ;
@@ -536,15 +536,15 @@ impl<'a> Printer<'a> {
536536 Ok ( ( ) )
537537 }
538538
539- pub fn print_end ( & mut self ) -> io:: Result < ( ) > {
539+ crate fn print_end ( & mut self ) -> io:: Result < ( ) > {
540540 debug ! ( "print End -> pop End" ) ;
541541 let print_stack = & mut self . print_stack ;
542542 assert ! ( !print_stack. is_empty( ) ) ;
543543 print_stack. pop ( ) . unwrap ( ) ;
544544 Ok ( ( ) )
545545 }
546546
547- pub fn print_break ( & mut self , b : BreakToken , l : isize ) -> io:: Result < ( ) > {
547+ crate fn print_break ( & mut self , b : BreakToken , l : isize ) -> io:: Result < ( ) > {
548548 let top = self . get_top ( ) ;
549549 match top. pbreak {
550550 PrintStackBreak :: Fits => {
@@ -578,7 +578,7 @@ impl<'a> Printer<'a> {
578578 }
579579 }
580580
581- pub fn print_string ( & mut self , s : Cow < ' static , str > , len : isize ) -> io:: Result < ( ) > {
581+ crate fn print_string ( & mut self , s : Cow < ' static , str > , len : isize ) -> io:: Result < ( ) > {
582582 debug ! ( "print String({})" , s) ;
583583 // assert!(len <= space);
584584 self . space -= len;
@@ -603,7 +603,7 @@ impl<'a> Printer<'a> {
603603 write ! ( self . out, "{}" , s)
604604 }
605605
606- pub fn print ( & mut self , token : Token , l : isize ) -> io:: Result < ( ) > {
606+ crate fn print ( & mut self , token : Token , l : isize ) -> io:: Result < ( ) > {
607607 debug ! ( "print {} {} (remaining line space={})" , token, l,
608608 self . space) ;
609609 debug ! ( "{}" , buf_str( & self . buf,
@@ -625,15 +625,15 @@ impl<'a> Printer<'a> {
625625 // Convenience functions to talk to the printer.
626626
627627 /// "raw box"
628- pub fn rbox ( & mut self , indent : usize , b : Breaks ) -> io:: Result < ( ) > {
628+ crate fn rbox ( & mut self , indent : usize , b : Breaks ) -> io:: Result < ( ) > {
629629 self . pretty_print_begin ( BeginToken {
630630 offset : indent as isize ,
631631 breaks : b
632632 } )
633633 }
634634
635635 /// Inconsistent breaking box
636- pub fn ibox ( & mut self , indent : usize ) -> io:: Result < ( ) > {
636+ crate fn ibox ( & mut self , indent : usize ) -> io:: Result < ( ) > {
637637 self . rbox ( indent, Breaks :: Inconsistent )
638638 }
639639
@@ -649,7 +649,7 @@ impl<'a> Printer<'a> {
649649 } )
650650 }
651651
652- pub fn end ( & mut self ) -> io:: Result < ( ) > {
652+ crate fn end ( & mut self ) -> io:: Result < ( ) > {
653653 self . pretty_print_end ( )
654654 }
655655
@@ -667,7 +667,7 @@ impl<'a> Printer<'a> {
667667 self . break_offset ( n, 0 )
668668 }
669669
670- pub fn zerobreak ( & mut self ) -> io:: Result < ( ) > {
670+ crate fn zerobreak ( & mut self ) -> io:: Result < ( ) > {
671671 self . spaces ( 0 )
672672 }
673673
@@ -683,7 +683,7 @@ impl<'a> Printer<'a> {
683683 Token :: Break ( BreakToken { offset : off, blank_space : SIZE_INFINITY } )
684684 }
685685
686- pub fn hardbreak_tok ( ) -> Token {
686+ crate fn hardbreak_tok ( ) -> Token {
687687 Self :: hardbreak_tok_offset ( 0 )
688688 }
689689}
0 commit comments