@@ -297,9 +297,9 @@ where
297297 } else {
298298 inner_item. as_ref ( )
299299 } ;
300- let mut item_last_line_width = item_last_line . len ( ) + item_sep_len;
300+ let mut item_last_line_width = unicode_str_width ( item_last_line ) + item_sep_len;
301301 if item_last_line. starts_with ( & * * indent_str) {
302- item_last_line_width -= indent_str . len ( ) ;
302+ item_last_line_width -= unicode_str_width ( indent_str ) ;
303303 }
304304
305305 if !item. is_substantial ( ) {
@@ -449,7 +449,7 @@ where
449449 } else if starts_with_newline ( comment) {
450450 false
451451 } else {
452- comment. trim ( ) . contains ( '\n' ) || comment. trim ( ) . len ( ) > width
452+ comment. trim ( ) . contains ( '\n' ) || unicode_str_width ( comment. trim ( ) ) > width
453453 } ;
454454
455455 rewrite_comment (
@@ -465,7 +465,7 @@ where
465465 if !starts_with_newline ( comment) {
466466 if formatting. align_comments {
467467 let mut comment_alignment =
468- post_comment_alignment ( item_max_width, inner_item . len ( ) ) ;
468+ post_comment_alignment ( item_max_width, unicode_str_width ( inner_item ) ) ;
469469 if first_line_width ( & formatted_comment)
470470 + last_line_width ( & result)
471471 + comment_alignment
@@ -475,7 +475,7 @@ where
475475 item_max_width = None ;
476476 formatted_comment = rewrite_post_comment ( & mut item_max_width) ?;
477477 comment_alignment =
478- post_comment_alignment ( item_max_width, inner_item . len ( ) ) ;
478+ post_comment_alignment ( item_max_width, unicode_str_width ( inner_item ) ) ;
479479 }
480480 for _ in 0 ..=comment_alignment {
481481 result. push ( ' ' ) ;
@@ -533,7 +533,7 @@ where
533533 let mut first = true ;
534534 for item in items. clone ( ) . into_iter ( ) . skip ( i) {
535535 let item = item. as_ref ( ) ;
536- let inner_item_width = item. inner_as_ref ( ) . len ( ) ;
536+ let inner_item_width = unicode_str_width ( item. inner_as_ref ( ) ) ;
537537 if !first
538538 && ( item. is_different_group ( )
539539 || item. post_comment . is_none ( )
@@ -552,8 +552,8 @@ where
552552 max_width
553553}
554554
555- fn post_comment_alignment ( item_max_width : Option < usize > , inner_item_len : usize ) -> usize {
556- item_max_width. unwrap_or ( 0 ) . saturating_sub ( inner_item_len )
555+ fn post_comment_alignment ( item_max_width : Option < usize > , inner_item_width : usize ) -> usize {
556+ item_max_width. unwrap_or ( 0 ) . saturating_sub ( inner_item_width )
557557}
558558
559559pub ( crate ) struct ListItems < ' a , I , F1 , F2 , F3 >
0 commit comments