File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -72,18 +72,17 @@ impl<'a> fmt::Debug for DisplayList<'a> {
72
72
73
73
impl < ' a > Display for DisplayList < ' a > {
74
74
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
75
- let lineno_width = self . body . iter ( ) . fold ( 0 , |max, set| {
75
+ let lineno_width = self . body . iter ( ) . fold ( None , |max, set| {
76
76
set. display_lines . iter ( ) . fold ( max, |max, line| match line {
77
- DisplayLine :: Source { lineno, .. } => cmp:: max ( lineno . unwrap_or ( 0 ) , max ) ,
77
+ DisplayLine :: Source { lineno, .. } => std :: cmp:: max ( max , * lineno ) ,
78
78
_ => max,
79
79
} )
80
80
} ) ;
81
- let lineno_width = if lineno_width == 0 {
82
- lineno_width
83
- } else if self . anonymized_line_numbers {
84
- ANONYMIZED_LINE_NUM . len ( )
85
- } else {
86
- ( ( lineno_width as f64 ) . log10 ( ) . floor ( ) as usize ) + 1
81
+ let lineno_width = match lineno_width {
82
+ None => 0 ,
83
+ Some ( _max) if self . anonymized_line_numbers => ANONYMIZED_LINE_NUM . len ( ) ,
84
+ Some ( 0 ) => 1 ,
85
+ Some ( max) => ( max as f64 ) . log10 ( ) . floor ( ) as usize + 1 ,
87
86
} ;
88
87
89
88
let multiline_depth = self . body . iter ( ) . fold ( 0 , |max, set| {
You can’t perform that action at this time.
0 commit comments