@@ -2,6 +2,7 @@ use std::env::{consts::EXE_SUFFIX, split_paths};
2
2
use std:: ffi:: { OsStr , OsString } ;
3
3
use std:: fmt;
4
4
use std:: io:: Write ;
5
+ use std:: ops:: Deref ;
5
6
use std:: os:: windows:: ffi:: OsStrExt ;
6
7
use std:: path:: Path ;
7
8
use std:: process:: Command ;
@@ -530,9 +531,8 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option<HSTRING> {
530
531
if old_path. is_empty ( ) {
531
532
Some ( path_str)
532
533
} else if old_path
533
- . as_wide ( )
534
534
. windows ( path_str. len ( ) )
535
- . any ( |path| path == path_str. as_wide ( ) )
535
+ . any ( |path| path == path_str. deref ( ) )
536
536
{
537
537
None
538
538
} else {
@@ -546,20 +546,19 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option<HSTRING> {
546
546
// Returns None if the existing old_path does not need changing
547
547
fn _remove_from_path ( old_path : HSTRING , path_str : HSTRING ) -> Option < HSTRING > {
548
548
let idx = old_path
549
- . as_wide ( )
550
549
. windows ( path_str. len ( ) )
551
- . position ( |path| path == path_str. as_wide ( ) ) ?;
550
+ . position ( |path| path == path_str. deref ( ) ) ?;
552
551
// If there's a trailing semicolon (likely, since we probably added one
553
552
// during install), include that in the substring to remove. We don't search
554
553
// for that to find the string, because if it's the last string in the path,
555
554
// there may not be.
556
555
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 ) ) {
558
557
len += 1 ;
559
558
}
560
559
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..] ) ;
563
562
// Don't leave a trailing ; though, we don't want an empty string in the
564
563
// path.
565
564
if new_path. last ( ) == Some ( & ( b';' as u16 ) ) {
0 commit comments