Skip to content

Commit 00db126

Browse files
author
Yue Fei
committed
Update
1 parent ce0fedc commit 00db126

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

Cargo.lock

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/self_update/windows.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::env::{consts::EXE_SUFFIX, split_paths};
22
use std::ffi::{OsStr, OsString};
33
use std::fmt;
44
use std::io::Write;
5+
use std::ops::Deref;
56
use std::os::windows::ffi::OsStrExt;
67
use std::path::Path;
78
use std::process::Command;
@@ -530,9 +531,8 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option<HSTRING> {
530531
if old_path.is_empty() {
531532
Some(path_str)
532533
} else if old_path
533-
.as_wide()
534534
.windows(path_str.len())
535-
.any(|path| path == path_str.as_wide())
535+
.any(|path| path == path_str.deref())
536536
{
537537
None
538538
} else {
@@ -546,20 +546,19 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option<HSTRING> {
546546
// Returns None if the existing old_path does not need changing
547547
fn _remove_from_path(old_path: HSTRING, path_str: HSTRING) -> Option<HSTRING> {
548548
let idx = old_path
549-
.as_wide()
550549
.windows(path_str.len())
551-
.position(|path| path == path_str.as_wide())?;
550+
.position(|path| path == path_str.deref())?;
552551
// If there's a trailing semicolon (likely, since we probably added one
553552
// during install), include that in the substring to remove. We don't search
554553
// for that to find the string, because if it's the last string in the path,
555554
// there may not be.
556555
let mut len = path_str.len();
557-
if old_path.as_wide().get(idx + path_str.len()) == Some(&(b';' as u16)) {
556+
if old_path.get(idx + path_str.len()) == Some(&(b';' as u16)) {
558557
len += 1;
559558
}
560559

561-
let mut new_path = old_path.as_wide()[..idx].to_owned();
562-
new_path.extend_from_slice(&old_path.as_wide()[idx + len..]);
560+
let mut new_path = old_path[..idx].to_owned();
561+
new_path.extend_from_slice(&old_path[idx + len..]);
563562
// Don't leave a trailing ; though, we don't want an empty string in the
564563
// path.
565564
if new_path.last() == Some(&(b';' as u16)) {

0 commit comments

Comments
 (0)