@@ -176,15 +176,9 @@ impl Token {
176176}
177177
178178#[ derive( Copy , Clone ) ]
179- enum PrintStackBreak {
179+ enum PrintFrame {
180180 Fits ,
181- Broken ( Breaks ) ,
182- }
183-
184- #[ derive( Copy , Clone ) ]
185- struct PrintStackElem {
186- offset : isize ,
187- pbreak : PrintStackBreak ,
181+ Broken { offset : isize , breaks : Breaks } ,
188182}
189183
190184const SIZE_INFINITY : isize = 0xffff ;
@@ -209,7 +203,7 @@ pub struct Printer {
209203 /// advancing.
210204 scan_stack : VecDeque < usize > ,
211205 /// Stack of blocks-in-progress being flushed by print
212- print_stack : Vec < PrintStackElem > ,
206+ print_stack : Vec < PrintFrame > ,
213207 /// Buffered indentation to avoid writing trailing whitespace
214208 pending_indentation : isize ,
215209 /// The token most recently popped from the left boundary of the
@@ -380,21 +374,19 @@ impl Printer {
380374 self . pending_indentation += amount;
381375 }
382376
383- fn get_top ( & self ) -> PrintStackElem {
384- * self . print_stack . last ( ) . unwrap_or ( {
385- & PrintStackElem { offset : 0 , pbreak : PrintStackBreak :: Broken ( Breaks :: Inconsistent ) }
386- } )
377+ fn get_top ( & self ) -> PrintFrame {
378+ * self
379+ . print_stack
380+ . last ( )
381+ . unwrap_or ( & PrintFrame :: Broken { offset : 0 , breaks : Breaks :: Inconsistent } )
387382 }
388383
389384 fn print_begin ( & mut self , token : BeginToken , size : isize ) {
390385 if size > self . space {
391386 let col = self . margin - self . space + token. offset ;
392- self . print_stack . push ( PrintStackElem {
393- offset : col,
394- pbreak : PrintStackBreak :: Broken ( token. breaks ) ,
395- } ) ;
387+ self . print_stack . push ( PrintFrame :: Broken { offset : col, breaks : token. breaks } ) ;
396388 } else {
397- self . print_stack . push ( PrintStackElem { offset : 0 , pbreak : PrintStackBreak :: Fits } ) ;
389+ self . print_stack . push ( PrintFrame :: Fits ) ;
398390 }
399391 }
400392
@@ -403,20 +395,19 @@ impl Printer {
403395 }
404396
405397 fn print_break ( & mut self , token : BreakToken , size : isize ) {
406- let top = self . get_top ( ) ;
407- match top. pbreak {
408- PrintStackBreak :: Fits => {
409- self . space -= token. blank_space ;
398+ match self . get_top ( ) {
399+ PrintFrame :: Fits => {
410400 self . indent ( token. blank_space ) ;
401+ self . space -= token. blank_space ;
411402 }
412- PrintStackBreak :: Broken ( Breaks :: Consistent ) => {
413- self . print_newline ( top . offset + token. offset ) ;
414- self . space = self . margin - ( top . offset + token. offset ) ;
403+ PrintFrame :: Broken { offset , breaks : Breaks :: Consistent } => {
404+ self . print_newline ( offset + token. offset ) ;
405+ self . space = self . margin - ( offset + token. offset ) ;
415406 }
416- PrintStackBreak :: Broken ( Breaks :: Inconsistent ) => {
407+ PrintFrame :: Broken { offset , breaks : Breaks :: Inconsistent } => {
417408 if size > self . space {
418- self . print_newline ( top . offset + token. offset ) ;
419- self . space = self . margin - ( top . offset + token. offset ) ;
409+ self . print_newline ( offset + token. offset ) ;
410+ self . space = self . margin - ( offset + token. offset ) ;
420411 } else {
421412 self . indent ( token. blank_space ) ;
422413 self . space -= token. blank_space ;
0 commit comments