@@ -106,7 +106,7 @@ fn get_chunks_of_tabs(the_str: &str) -> Vec<(u32, u32)> {
106106
107107 let char_indices: Vec < _ > = the_str. char_indices ( ) . collect ( ) ;
108108
109- if let & [ ( _, '\t' ) ] = & char_indices. as_slice ( ) {
109+ if let [ ( _, '\t' ) ] = char_indices. as_slice ( ) {
110110 return vec ! [ ( 0 , 1 ) ] ;
111111 }
112112
@@ -121,12 +121,12 @@ fn get_chunks_of_tabs(the_str: &str) -> Vec<(u32, u32)> {
121121 // as ['\t', '\t'] is excluded, this has to be a start of a tab group,
122122 // set indices accordingly
123123 is_active = true ;
124- current_start = * index_b as u32 ;
124+ current_start = u32 :: try_from ( * index_b) . unwrap ( ) ;
125125 } ,
126126 [ ( _, '\t' ) , ( index_b, _) ] => {
127127 // this now has to be an end of the group, hence we have to push a new tuple
128128 is_active = false ;
129- spans. push ( ( current_start, * index_b as u32 ) ) ;
129+ spans. push ( ( current_start, u32 :: try_from ( * index_b) . unwrap ( ) ) ) ;
130130 } ,
131131 _ => { } ,
132132 }
@@ -149,7 +149,7 @@ mod tests_for_get_chunks_of_tabs {
149149
150150 #[ test]
151151 fn test_unicode_han_string ( ) {
152- let res = get_chunks_of_tabs ( " 位 \t " ) ;
152+ let res = get_chunks_of_tabs ( " \u{4f4d} \t " ) ;
153153
154154 assert_eq ! ( res, vec![ ( 4 , 5 ) ] ) ;
155155 }
0 commit comments