@@ -222,29 +222,6 @@ struct PrintStackElem {
222222
223223const SIZE_INFINITY : isize = 0xffff ;
224224
225- pub fn mk_printer ( ) -> Printer {
226- let linewidth = 78 ;
227- // Yes 55, it makes the ring buffers big enough to never fall behind.
228- let n: usize = 55 * linewidth;
229- debug ! ( "mk_printer {}" , linewidth) ;
230- Printer {
231- out : String :: new ( ) ,
232- buf_max_len : n,
233- margin : linewidth as isize ,
234- space : linewidth as isize ,
235- left : 0 ,
236- right : 0 ,
237- // Initialize a single entry; advance_right() will extend it on demand
238- // up to `buf_max_len` elements.
239- buf : vec ! [ BufEntry :: default ( ) ] ,
240- left_total : 0 ,
241- right_total : 0 ,
242- scan_stack : VecDeque :: new ( ) ,
243- print_stack : Vec :: new ( ) ,
244- pending_indentation : 0 ,
245- }
246- }
247-
248225pub struct Printer {
249226 out : String ,
250227 buf_max_len : usize ,
@@ -288,6 +265,29 @@ impl Default for BufEntry {
288265}
289266
290267impl Printer {
268+ pub fn new ( ) -> Self {
269+ let linewidth = 78 ;
270+ // Yes 55, it makes the ring buffers big enough to never fall behind.
271+ let n: usize = 55 * linewidth;
272+ debug ! ( "Printer::new {}" , linewidth) ;
273+ Printer {
274+ out : String :: new ( ) ,
275+ buf_max_len : n,
276+ margin : linewidth as isize ,
277+ space : linewidth as isize ,
278+ left : 0 ,
279+ right : 0 ,
280+ // Initialize a single entry; advance_right() will extend it on demand
281+ // up to `buf_max_len` elements.
282+ buf : vec ! [ BufEntry :: default ( ) ] ,
283+ left_total : 0 ,
284+ right_total : 0 ,
285+ scan_stack : VecDeque :: new ( ) ,
286+ print_stack : Vec :: new ( ) ,
287+ pending_indentation : 0 ,
288+ }
289+ }
290+
291291 pub fn last_token ( & self ) -> Token {
292292 self . buf [ self . right ] . token . clone ( )
293293 }
0 commit comments