@@ -83,7 +83,7 @@ pub fn component(
83
83
if input. find_byteset ( b"/\\ " ) . is_some ( ) {
84
84
return Err ( component:: Error :: PathSeparator ) ;
85
85
}
86
- if input. chars ( ) . skip ( 1 ) . next ( ) == Some ( ':' ) {
86
+ if input. chars ( ) . nth ( 1 ) == Some ( ':' ) {
87
87
return Err ( component:: Error :: WindowsPathPrefix ) ;
88
88
}
89
89
} else if input. find_byte ( b'/' ) . is_some ( ) {
@@ -142,7 +142,7 @@ fn check_win_devices_and_illegal_characters(input: &BStr) -> Option<component::E
142
142
return Some ( component:: Error :: WindowsReservedName ) ;
143
143
}
144
144
if in3. eq_ignore_ascii_case ( b"lpt" )
145
- && input. get ( 3 ) . map_or ( false , |n| n . is_ascii_digit ( ) )
145
+ && input. get ( 3 ) . map_or ( false , u8 :: is_ascii_digit)
146
146
&& is_done_windows ( input. get ( 4 ..) )
147
147
{
148
148
return Some ( component:: Error :: WindowsReservedName ) ;
@@ -153,7 +153,7 @@ fn check_win_devices_and_illegal_characters(input: &BStr) -> Option<component::E
153
153
{
154
154
return Some ( component:: Error :: WindowsReservedName ) ;
155
155
}
156
- if input. iter ( ) . find ( |b| * * b < 0x20 || b":<>\" |?*" . contains ( b) ) . is_some ( ) {
156
+ if input. iter ( ) . any ( |b| * b < 0x20 || b":<>\" |?*" . contains ( b) ) {
157
157
return Some ( component:: Error :: WindowsIllegalCharacter ) ;
158
158
}
159
159
if input. ends_with ( b"." ) || input. ends_with ( b" " ) {
@@ -221,7 +221,7 @@ fn is_dot_git_ntfs(input: &BStr) -> bool {
221
221
}
222
222
223
223
fn is_dot_ntfs ( input : & BStr , search_case_insensitive : & str , ntfs_shortname_prefix : & str ) -> bool {
224
- if input. get ( 0 ) == Some ( & b'.' ) {
224
+ if input. first ( ) == Some ( & b'.' ) {
225
225
let end_pos = 1 + search_case_insensitive. len ( ) ;
226
226
if input. get ( 1 ..end_pos) . map_or ( false , |input| {
227
227
input. eq_ignore_ascii_case ( search_case_insensitive. as_bytes ( ) )
@@ -238,7 +238,7 @@ fn is_dot_ntfs(input: &BStr, search_case_insensitive: &str, ntfs_shortname_prefi
238
238
. map_or ( false , |( ntfs_prefix, first_6_of_input) | {
239
239
first_6_of_input. eq_ignore_ascii_case ( ntfs_prefix)
240
240
&& input. get ( 6 ) == Some ( & b'~' )
241
- && input. get ( 7 ) . map_or ( false , |num| num >= & b'1' && num <= & b'4' )
241
+ && input. get ( 7 ) . map_or ( false , |num| ( b'1' ..= b'4' ) . contains ( num ) )
242
242
} )
243
243
{
244
244
return is_done_ntfs ( input. get ( 8 ..) ) ;
@@ -252,7 +252,7 @@ fn is_dot_ntfs(input: &BStr, search_case_insensitive: &str, ntfs_shortname_prefi
252
252
return false ;
253
253
} ;
254
254
if saw_tilde {
255
- if b < b'0' || b > b'9' {
255
+ if !b . is_ascii_digit ( ) {
256
256
return false ;
257
257
}
258
258
} else if b == b'~' {
@@ -261,16 +261,14 @@ fn is_dot_ntfs(input: &BStr, search_case_insensitive: &str, ntfs_shortname_prefi
261
261
let Some ( b) = input. get ( pos) . copied ( ) else {
262
262
return false ;
263
263
} ;
264
- if b < b '1' || b > b '9' {
264
+ if ! ( b '1'..= b '9') . contains ( & b ) {
265
265
return false ;
266
266
}
267
- } else if pos >= 6 {
268
- return false ;
269
- } else if b & 0x80 == 0x80 {
270
- return false ;
271
- } else if ntfs_shortname_prefix
272
- . get ( pos)
273
- . map_or ( true , |ob| !b. eq_ignore_ascii_case ( ob) )
267
+ } else if pos >= 6
268
+ || b & 0x80 == 0x80
269
+ || ntfs_shortname_prefix
270
+ . get ( pos)
271
+ . map_or ( true , |ob| !b. eq_ignore_ascii_case ( ob) )
274
272
{
275
273
return false ;
276
274
}
0 commit comments