@@ -594,9 +594,9 @@ impl EmitterWriter {
594
594
595
595
let left = margin. left ( source_string. len ( ) ) ; // Left trim
596
596
// Account for unicode characters of width !=0 that were removed.
597
- let left = source_string. chars ( ) . take ( left) . fold ( 0 , |acc , ch| {
598
- acc + unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 )
599
- } ) ;
597
+ let left = source_string. chars ( ) . take ( left)
598
+ . map ( |ch| unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 ) )
599
+ . sum ( ) ;
600
600
601
601
self . draw_line (
602
602
buffer,
@@ -1512,9 +1512,9 @@ impl EmitterWriter {
1512
1512
. saturating_sub ( part. snippet . trim_start ( ) . len ( ) ) ;
1513
1513
// ...or trailing spaces. Account for substitutions containing unicode
1514
1514
// characters.
1515
- let sub_len = part. snippet . trim ( ) . chars ( ) . fold ( 0 , |acc , ch| {
1516
- acc + unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 )
1517
- } ) ;
1515
+ let sub_len = part. snippet . trim ( ) . chars ( )
1516
+ . map ( |ch| unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 ) )
1517
+ . sum ( ) ;
1518
1518
1519
1519
let underline_start = ( span_start_pos + start) as isize + offset;
1520
1520
let underline_end = ( span_start_pos + start + sub_len) as isize + offset;
@@ -1535,9 +1535,9 @@ impl EmitterWriter {
1535
1535
}
1536
1536
1537
1537
// length of the code after substitution
1538
- let full_sub_len = part. snippet . chars ( ) . fold ( 0 , |acc , ch| {
1539
- acc + unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 ) as isize
1540
- } ) ;
1538
+ let full_sub_len = part. snippet . chars ( )
1539
+ . map ( |ch| acc + unicode_width:: UnicodeWidthChar :: width ( ch) . unwrap_or ( 1 ) )
1540
+ . sum ( ) as isize ;
1541
1541
1542
1542
// length of the code to be substituted
1543
1543
let snippet_len = span_end_pos as isize - span_start_pos as isize ;
0 commit comments