File tree 1 file changed +10
-11
lines changed 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ cfg_if::cfg_if! {
6
6
use std:: fmt;
7
7
use std:: path:: PathBuf ;
8
8
use std:: prelude:: v1:: * ;
9
+ use std:: str ;
9
10
}
10
11
}
11
12
@@ -47,32 +48,30 @@ impl<'a> BytesOrWideString<'a> {
47
48
pub fn into_path_buf ( self ) -> PathBuf {
48
49
#[ cfg( unix) ]
49
50
{
50
- use self :: BytesOrWideString :: * ;
51
51
use std:: ffi:: OsStr ;
52
52
use std:: os:: unix:: ffi:: OsStrExt ;
53
53
54
- match self {
55
- Bytes ( slice) => PathBuf :: from ( OsStr :: from_bytes ( slice) ) ,
56
- _ => unreachable ! ( ) ,
54
+ if let BytesOrWideString :: Bytes ( slice) = self {
55
+ return PathBuf :: from ( OsStr :: from_bytes ( slice) )
57
56
}
58
57
}
59
58
60
59
#[ cfg( windows) ]
61
60
{
62
- use self :: BytesOrWideString :: * ;
63
61
use std:: ffi:: OsString ;
64
62
use std:: os:: windows:: ffi:: OsStringExt ;
65
63
66
- match self {
67
- Wide ( slice) => PathBuf :: from ( OsString :: from_wide ( slice) ) ,
68
- _ => unreachable ! ( ) ,
64
+ if let BytesOrWideString :: Wide ( slice) = self {
65
+ return PathBuf :: from ( OsString :: from_wide ( slice) )
69
66
}
70
67
}
71
68
72
- #[ cfg( all( not( windows) , not( unix) ) ) ]
73
- {
74
- unreachable ! ( )
69
+ if let BytesOrWideString :: Bytes ( b) = self {
70
+ if let Ok ( s) = str:: from_utf8 ( b) {
71
+ return PathBuf :: from ( s)
72
+ }
75
73
}
74
+ unreachable ! ( )
76
75
}
77
76
}
78
77
You can’t perform that action at this time.
0 commit comments