@@ -172,7 +172,7 @@ pub enum Token {
172
172
}
173
173
174
174
impl Token {
175
- pub fn is_eof ( & self ) -> bool {
175
+ crate fn is_eof ( & self ) -> bool {
176
176
match * self {
177
177
Token :: Eof => true ,
178
178
_ => false ,
@@ -223,13 +223,13 @@ fn buf_str(buf: &[BufEntry], left: usize, right: usize, lim: usize) -> String {
223
223
}
224
224
225
225
#[ derive( Copy , Clone ) ]
226
- pub enum PrintStackBreak {
226
+ crate enum PrintStackBreak {
227
227
Fits ,
228
228
Broken ( Breaks ) ,
229
229
}
230
230
231
231
#[ derive( Copy , Clone ) ]
232
- pub struct PrintStackElem {
232
+ crate struct PrintStackElem {
233
233
offset : isize ,
234
234
pbreak : PrintStackBreak
235
235
}
@@ -386,7 +386,7 @@ impl<'a> Printer<'a> {
386
386
}
387
387
}
388
388
389
- pub fn check_stream ( & mut self ) -> io:: Result < ( ) > {
389
+ crate fn check_stream ( & mut self ) -> io:: Result < ( ) > {
390
390
debug ! ( "check_stream Vec<{}, {}> with left_total={}, right_total={}" ,
391
391
self . left, self . right, self . left_total, self . right_total) ;
392
392
if self . right_total - self . left_total > self . space {
@@ -405,24 +405,24 @@ impl<'a> Printer<'a> {
405
405
Ok ( ( ) )
406
406
}
407
407
408
- pub fn scan_push ( & mut self , x : usize ) {
408
+ crate fn scan_push ( & mut self , x : usize ) {
409
409
debug ! ( "scan_push {}" , x) ;
410
410
self . scan_stack . push_front ( x) ;
411
411
}
412
412
413
- pub fn scan_pop ( & mut self ) -> usize {
413
+ crate fn scan_pop ( & mut self ) -> usize {
414
414
self . scan_stack . pop_front ( ) . unwrap ( )
415
415
}
416
416
417
- pub fn scan_top ( & mut self ) -> usize {
417
+ crate fn scan_top ( & mut self ) -> usize {
418
418
* self . scan_stack . front ( ) . unwrap ( )
419
419
}
420
420
421
- pub fn scan_pop_bottom ( & mut self ) -> usize {
421
+ crate fn scan_pop_bottom ( & mut self ) -> usize {
422
422
self . scan_stack . pop_back ( ) . unwrap ( )
423
423
}
424
424
425
- pub fn advance_right ( & mut self ) {
425
+ crate fn advance_right ( & mut self ) {
426
426
self . right += 1 ;
427
427
self . right %= self . buf_max_len ;
428
428
// Extend the buf if necessary.
@@ -432,7 +432,7 @@ impl<'a> Printer<'a> {
432
432
assert_ne ! ( self . right, self . left) ;
433
433
}
434
434
435
- pub fn advance_left ( & mut self ) -> io:: Result < ( ) > {
435
+ crate fn advance_left ( & mut self ) -> io:: Result < ( ) > {
436
436
debug ! ( "advance_left Vec<{},{}>, sizeof({})={}" , self . left, self . right,
437
437
self . left, self . buf[ self . left] . size) ;
438
438
@@ -467,7 +467,7 @@ impl<'a> Printer<'a> {
467
467
Ok ( ( ) )
468
468
}
469
469
470
- pub fn check_stack ( & mut self , k : isize ) {
470
+ crate fn check_stack ( & mut self , k : isize ) {
471
471
if !self . scan_stack . is_empty ( ) {
472
472
let x = self . scan_top ( ) ;
473
473
match self . buf [ x] . token {
@@ -495,20 +495,20 @@ impl<'a> Printer<'a> {
495
495
}
496
496
}
497
497
498
- pub fn print_newline ( & mut self , amount : isize ) -> io:: Result < ( ) > {
498
+ crate fn print_newline ( & mut self , amount : isize ) -> io:: Result < ( ) > {
499
499
debug ! ( "NEWLINE {}" , amount) ;
500
500
let ret = writeln ! ( self . out) ;
501
501
self . pending_indentation = 0 ;
502
502
self . indent ( amount) ;
503
503
ret
504
504
}
505
505
506
- pub fn indent ( & mut self , amount : isize ) {
506
+ crate fn indent ( & mut self , amount : isize ) {
507
507
debug ! ( "INDENT {}" , amount) ;
508
508
self . pending_indentation += amount;
509
509
}
510
510
511
- pub fn get_top ( & mut self ) -> PrintStackElem {
511
+ crate fn get_top ( & mut self ) -> PrintStackElem {
512
512
match self . print_stack . last ( ) {
513
513
Some ( el) => * el,
514
514
None => PrintStackElem {
@@ -518,7 +518,7 @@ impl<'a> Printer<'a> {
518
518
}
519
519
}
520
520
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 < ( ) > {
522
522
if l > self . space {
523
523
let col = self . margin - self . space + b. offset ;
524
524
debug ! ( "print Begin -> push broken block at col {}" , col) ;
@@ -536,15 +536,15 @@ impl<'a> Printer<'a> {
536
536
Ok ( ( ) )
537
537
}
538
538
539
- pub fn print_end ( & mut self ) -> io:: Result < ( ) > {
539
+ crate fn print_end ( & mut self ) -> io:: Result < ( ) > {
540
540
debug ! ( "print End -> pop End" ) ;
541
541
let print_stack = & mut self . print_stack ;
542
542
assert ! ( !print_stack. is_empty( ) ) ;
543
543
print_stack. pop ( ) . unwrap ( ) ;
544
544
Ok ( ( ) )
545
545
}
546
546
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 < ( ) > {
548
548
let top = self . get_top ( ) ;
549
549
match top. pbreak {
550
550
PrintStackBreak :: Fits => {
@@ -578,7 +578,7 @@ impl<'a> Printer<'a> {
578
578
}
579
579
}
580
580
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 < ( ) > {
582
582
debug ! ( "print String({})" , s) ;
583
583
// assert!(len <= space);
584
584
self . space -= len;
@@ -603,7 +603,7 @@ impl<'a> Printer<'a> {
603
603
write ! ( self . out, "{}" , s)
604
604
}
605
605
606
- pub fn print ( & mut self , token : Token , l : isize ) -> io:: Result < ( ) > {
606
+ crate fn print ( & mut self , token : Token , l : isize ) -> io:: Result < ( ) > {
607
607
debug ! ( "print {} {} (remaining line space={})" , token, l,
608
608
self . space) ;
609
609
debug ! ( "{}" , buf_str( & self . buf,
@@ -625,15 +625,15 @@ impl<'a> Printer<'a> {
625
625
// Convenience functions to talk to the printer.
626
626
627
627
/// "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 < ( ) > {
629
629
self . pretty_print_begin ( BeginToken {
630
630
offset : indent as isize ,
631
631
breaks : b
632
632
} )
633
633
}
634
634
635
635
/// Inconsistent breaking box
636
- pub fn ibox ( & mut self , indent : usize ) -> io:: Result < ( ) > {
636
+ crate fn ibox ( & mut self , indent : usize ) -> io:: Result < ( ) > {
637
637
self . rbox ( indent, Breaks :: Inconsistent )
638
638
}
639
639
@@ -649,7 +649,7 @@ impl<'a> Printer<'a> {
649
649
} )
650
650
}
651
651
652
- pub fn end ( & mut self ) -> io:: Result < ( ) > {
652
+ crate fn end ( & mut self ) -> io:: Result < ( ) > {
653
653
self . pretty_print_end ( )
654
654
}
655
655
@@ -667,7 +667,7 @@ impl<'a> Printer<'a> {
667
667
self . break_offset ( n, 0 )
668
668
}
669
669
670
- pub fn zerobreak ( & mut self ) -> io:: Result < ( ) > {
670
+ crate fn zerobreak ( & mut self ) -> io:: Result < ( ) > {
671
671
self . spaces ( 0 )
672
672
}
673
673
@@ -683,7 +683,7 @@ impl<'a> Printer<'a> {
683
683
Token :: Break ( BreakToken { offset : off, blank_space : SIZE_INFINITY } )
684
684
}
685
685
686
- pub fn hardbreak_tok ( ) -> Token {
686
+ crate fn hardbreak_tok ( ) -> Token {
687
687
Self :: hardbreak_tok_offset ( 0 )
688
688
}
689
689
}
0 commit comments