@@ -156,7 +156,7 @@ mod platform {
156
156
None
157
157
}
158
158
159
- #[ derive( Copy , Clone , Show , Hash , PartialEq , Eq ) ]
159
+ #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
160
160
pub struct Prefix < ' a > ;
161
161
162
162
impl < ' a > Prefix < ' a > {
@@ -177,9 +177,10 @@ mod platform {
177
177
mod platform {
178
178
use core:: prelude:: * ;
179
179
180
- use super :: { Path , os_str_as_u8_slice , u8_slice_as_os_str } ;
181
- use ffi :: OsStr ;
180
+ use char :: CharExt as UnicodeCharExt ;
181
+ use super :: { os_str_as_u8_slice , u8_slice_as_os_str } ;
182
182
use ascii:: * ;
183
+ use ffi:: OsStr ;
183
184
184
185
#[ inline]
185
186
pub fn is_sep ( b : u8 ) -> bool {
@@ -299,7 +300,7 @@ mod platform {
299
300
pub fn len ( & self ) -> usize {
300
301
use self :: Prefix :: * ;
301
302
fn os_str_len ( s : & OsStr ) -> usize {
302
- unsafe { os_str_as_u8_slice ( s) . len ( ) }
303
+ os_str_as_u8_slice ( s) . len ( )
303
304
}
304
305
match * self {
305
306
Verbatim ( x) => 4 + os_str_len ( x) ,
@@ -339,12 +340,12 @@ mod platform {
339
340
}
340
341
}
341
342
342
- impl < ' a > ops :: PartialEq for Prefix < ' a > {
343
+ impl < ' a > PartialEq for Prefix < ' a > {
343
344
fn eq ( & self , other : & Prefix < ' a > ) -> bool {
344
345
use self :: Prefix :: * ;
345
346
match ( * self , * other) {
346
347
( Verbatim ( x) , Verbatim ( y) ) => x == y,
347
- ( VerbatimUNC ( x1, x2) , Verbatim ( y1, y2) ) => x1 == y1 && x2 == y2,
348
+ ( VerbatimUNC ( x1, x2) , VerbatimUNC ( y1, y2) ) => x1 == y1 && x2 == y2,
348
349
( VerbatimDisk ( x) , VerbatimDisk ( y) ) =>
349
350
os_str_as_u8_slice ( x) . eq_ignore_ascii_case ( os_str_as_u8_slice ( y) ) ,
350
351
( DeviceNS ( x) , DeviceNS ( y) ) => x == y,
@@ -457,7 +458,7 @@ fn split_file_at_dot(file: &OsStr) -> (Option<&OsStr>, Option<&OsStr>) {
457
458
/// Going front to back, a path is made up of a prefix, a root component, a body
458
459
/// (of normal components), and a suffix/emptycomponent (normalized `.` or ``
459
460
/// for a path ending with the separator)
460
- #[ derive( Copy , Clone , PartialEq , PartialOrd , Show ) ]
461
+ #[ derive( Copy , Clone , PartialEq , PartialOrd , Debug ) ]
461
462
enum State {
462
463
Prefix = 0 , // c:
463
464
Root = 1 , // /
@@ -470,7 +471,7 @@ enum State {
470
471
///
471
472
/// See the module documentation for an in-depth explanation of components and
472
473
/// their role in the API.
473
- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Show ) ]
474
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
474
475
pub enum Component < ' a > {
475
476
/// A Windows path prefix, e.g. `C:` or `\server\share`
476
477
Prefix ( & ' a OsStr ) ,
@@ -2434,12 +2435,21 @@ mod tests {
2434
2435
tfn ! ( "foo" , "bar" , "bar" ) ;
2435
2436
tfn ! ( "foo" , "" , "" ) ;
2436
2437
tfn ! ( "" , "foo" , "foo" ) ;
2437
- tfn ! ( "." , "foo" , "./foo" ) ;
2438
- tfn ! ( "foo/" , "bar" , "foo/bar" ) ;
2439
- tfn ! ( "foo/." , "bar" , "foo/./bar" ) ;
2440
- tfn ! ( ".." , "foo" , "../foo" ) ;
2441
- tfn ! ( "foo/.." , "bar" , "foo/../bar" ) ;
2442
- tfn ! ( "/" , "foo" , "/foo" ) ;
2438
+ if cfg ! ( unix) {
2439
+ tfn ! ( "." , "foo" , "./foo" ) ;
2440
+ tfn ! ( "foo/" , "bar" , "foo/bar" ) ;
2441
+ tfn ! ( "foo/." , "bar" , "foo/./bar" ) ;
2442
+ tfn ! ( ".." , "foo" , "../foo" ) ;
2443
+ tfn ! ( "foo/.." , "bar" , "foo/../bar" ) ;
2444
+ tfn ! ( "/" , "foo" , "/foo" ) ;
2445
+ } else {
2446
+ tfn ! ( "." , "foo" , r".\foo" ) ;
2447
+ tfn ! ( r"foo\" , "bar" , r"foo\bar" ) ;
2448
+ tfn ! ( r"foo\." , "bar" , r"foo\.\bar" ) ;
2449
+ tfn ! ( ".." , "foo" , r"..\foo" ) ;
2450
+ tfn ! ( r"foo\.." , "bar" , r"foo\..\bar" ) ;
2451
+ tfn ! ( r"\" , "foo" , r"\foo" ) ;
2452
+ }
2443
2453
}
2444
2454
2445
2455
#[ test]
0 commit comments