@@ -764,11 +764,7 @@ impl EmitterWriter {
764764 annotations_position. push ( ( p, annotation) ) ;
765765 for ( j, next) in annotations. iter ( ) . enumerate ( ) {
766766 if j > i {
767- let l = if let Some ( ref label) = next. label {
768- label. len ( ) + 2
769- } else {
770- 0
771- } ;
767+ let l = next. label . map_or ( 0 , |label| label. len ( ) + 2 ) ;
772768 if ( overlaps ( next, annotation, l) // Do not allow two labels to be in the same
773769 // line if they overlap including padding, to
774770 // avoid situations like:
@@ -1311,13 +1307,12 @@ impl EmitterWriter {
13111307 for line in & annotated_file. lines {
13121308 max_line_len = max ( max_line_len, annotated_file. file
13131309 . get_line ( line. line_index - 1 )
1314- . map ( |s| s. len ( ) )
1315- . unwrap_or ( 0 ) ) ;
1310+ . map_or ( 0 , |s| s. len ( ) ) ;
13161311 for ann in & line. annotations {
13171312 span_right_margin = max ( span_right_margin, ann. start_col ) ;
13181313 span_right_margin = max ( span_right_margin, ann. end_col ) ;
13191314 // FIXME: account for labels not in the same line
1320- let label_right = ann. label . as_ref ( ) . map ( |l| l. len ( ) + 1 ) . unwrap_or ( 0 ) ;
1315+ let label_right = ann. label . as_ref ( ) . map_or ( 0 , |l| l. len ( ) + 1 ) ;
13211316 label_right_margin = max ( label_right_margin, ann. end_col + label_right) ;
13221317 }
13231318 }
0 commit comments