Skip to content

Commit e0d5968

Browse files
committed
refactor
1 parent 1ab9bc3 commit e0d5968

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/windows.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
use std::{ffi::{OsStr,OsString}, io, os::windows::ffi::OsStrExt, ptr};
1+
use std::{
2+
ffi::{OsStr, OsString},
3+
io,
4+
os::windows::ffi::OsStrExt,
5+
ptr,
6+
};
27

38
use std::os::raw::c_int;
49
use windows_sys::Win32::UI::Shell::ShellExecuteW;
510

611
use crate::IntoResult;
712

813
fn convert_path(path: &OsStr) -> io::Result<Vec<u16>> {
9-
// Surround path with double quotes "" to handle spaces in path.
1014
let mut quoted_path = OsString::with_capacity(path.len());
15+
16+
// Surround path with double quotes "" to handle spaces in path.
1117
quoted_path.push("\"");
1218
quoted_path.push(&path);
1319
quoted_path.push("\"");
1420

15-
let mut maybe_result: Vec<_> = quoted_path.encode_wide().collect();
16-
if maybe_result.iter().any(|&u| u == 0) {
21+
let mut wide_chars: Vec<_> = quoted_path.encode_wide().collect();
22+
if wide_chars.iter().any(|&u| u == 0) {
1723
return Err(io::Error::new(
1824
io::ErrorKind::InvalidInput,
1925
"path contains NUL byte(s)",
2026
));
2127
}
22-
maybe_result.push(0);
23-
Ok(maybe_result)
28+
wide_chars.push(0);
29+
Ok(wide_chars)
2430
}
2531

2632
pub fn that<T: AsRef<OsStr>>(path: T) -> io::Result<()> {

0 commit comments

Comments
 (0)