@@ -72,12 +72,7 @@ impl<'a> fmt::Debug for DisplayList<'a> {
7272
7373impl < ' a > Display for DisplayList < ' a > {
7474 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
75- let max_lineno = self . body . iter ( ) . fold ( None , |max, set| {
76- set. display_lines . iter ( ) . fold ( max, |max, line| match line {
77- DisplayLine :: Source { lineno, .. } => std:: cmp:: max ( max, * lineno) ,
78- _ => max,
79- } )
80- } ) ;
75+ let max_lineno = get_max_lineno ( & self . body ) ;
8176 let lineno_width = match max_lineno {
8277 None => 0 ,
8378 Some ( _max) if self . anonymized_line_numbers => ANONYMIZED_LINE_NUM . len ( ) ,
@@ -149,6 +144,16 @@ impl<'a> DisplayList<'a> {
149144 }
150145}
151146
147+ fn get_max_lineno ( body : & Vec < DisplaySet < ' _ > > ) -> Option < usize > {
148+ let max_lineno = body. iter ( ) . fold ( None , |max, set| {
149+ set. display_lines . iter ( ) . fold ( max, |max, line| match line {
150+ DisplayLine :: Source { lineno, .. } => std:: cmp:: max ( max, * lineno) ,
151+ _ => max,
152+ } )
153+ } ) ;
154+ max_lineno
155+ }
156+
152157#[ derive( Debug , PartialEq ) ]
153158pub ( crate ) struct DisplaySet < ' a > {
154159 pub ( crate ) display_lines : Vec < DisplayLine < ' a > > ,
0 commit comments