@@ -106,7 +106,7 @@ fn get_chunks_of_tabs(the_str: &str) -> Vec<(u32, u32)> {
106
106
107
107
let char_indices: Vec < _ > = the_str. char_indices ( ) . collect ( ) ;
108
108
109
- if let & [ ( _, '\t' ) ] = & char_indices. as_slice ( ) {
109
+ if let [ ( _, '\t' ) ] = char_indices. as_slice ( ) {
110
110
return vec ! [ ( 0 , 1 ) ] ;
111
111
}
112
112
@@ -121,12 +121,12 @@ fn get_chunks_of_tabs(the_str: &str) -> Vec<(u32, u32)> {
121
121
// as ['\t', '\t'] is excluded, this has to be a start of a tab group,
122
122
// set indices accordingly
123
123
is_active = true ;
124
- current_start = * index_b as u32 ;
124
+ current_start = u32 :: try_from ( * index_b) . unwrap ( ) ;
125
125
} ,
126
126
[ ( _, '\t' ) , ( index_b, _) ] => {
127
127
// this now has to be an end of the group, hence we have to push a new tuple
128
128
is_active = false ;
129
- spans. push ( ( current_start, * index_b as u32 ) ) ;
129
+ spans. push ( ( current_start, u32 :: try_from ( * index_b) . unwrap ( ) ) ) ;
130
130
} ,
131
131
_ => { } ,
132
132
}
@@ -149,7 +149,7 @@ mod tests_for_get_chunks_of_tabs {
149
149
150
150
#[ test]
151
151
fn test_unicode_han_string ( ) {
152
- let res = get_chunks_of_tabs ( " 位 \t " ) ;
152
+ let res = get_chunks_of_tabs ( " \u{4f4d} \t " ) ;
153
153
154
154
assert_eq ! ( res, vec![ ( 4 , 5 ) ] ) ;
155
155
}
0 commit comments