Skip to content

Commit 81f40c8

Browse files
committed
Fix windows build
1 parent c2f6afd commit 81f40c8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/types.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cfg_if::cfg_if! {
66
use std::fmt;
77
use std::path::PathBuf;
88
use std::prelude::v1::*;
9+
use std::str;
910
}
1011
}
1112

@@ -47,32 +48,30 @@ impl<'a> BytesOrWideString<'a> {
4748
pub fn into_path_buf(self) -> PathBuf {
4849
#[cfg(unix)]
4950
{
50-
use self::BytesOrWideString::*;
5151
use std::ffi::OsStr;
5252
use std::os::unix::ffi::OsStrExt;
5353

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))
5756
}
5857
}
5958

6059
#[cfg(windows)]
6160
{
62-
use self::BytesOrWideString::*;
6361
use std::ffi::OsString;
6462
use std::os::windows::ffi::OsStringExt;
6563

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))
6966
}
7067
}
7168

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+
}
7573
}
74+
unreachable!()
7675
}
7776
}
7877

0 commit comments

Comments
 (0)