5
5
#![ allow( warnings) ]
6
6
7
7
use std:: collections:: HashMap ;
8
- use std:: ffi:: OsStr ;
8
+ use std:: ffi:: { OsStr , OsString } ;
9
9
use std:: fmt:: { Debug , Formatter } ;
10
10
use std:: hash:: { Hash , Hasher } ;
11
11
use std:: path:: Path ;
@@ -77,9 +77,9 @@ pub struct CommandCacheKey {
77
77
/// [allow_failure]: BootstrapCommand::allow_failure
78
78
/// [delay_failure]: BootstrapCommand::delay_failure
79
79
pub struct BootstrapCommand {
80
- program : String ,
81
- args : Vec < String > ,
82
- envs : Vec < ( String , String ) > ,
80
+ program : OsString ,
81
+ args : Vec < OsString > ,
82
+ envs : Vec < ( OsString , OsString ) > ,
83
83
cwd : Option < PathBuf > ,
84
84
85
85
command : Command ,
@@ -98,8 +98,7 @@ impl<'a> BootstrapCommand {
98
98
}
99
99
100
100
pub fn arg < S : AsRef < OsStr > > ( & mut self , arg : S ) -> & mut Self {
101
- let arg_str = arg. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
102
- self . args . push ( arg_str. clone ( ) ) ;
101
+ self . args . push ( arg. as_ref ( ) . to_os_string ( ) ) ;
103
102
self . command . arg ( arg. as_ref ( ) ) ;
104
103
self
105
104
}
@@ -120,9 +119,7 @@ impl<'a> BootstrapCommand {
120
119
K : AsRef < OsStr > ,
121
120
V : AsRef < OsStr > ,
122
121
{
123
- let key_str = key. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
124
- let val_str = val. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
125
- self . envs . push ( ( key_str. clone ( ) , val_str. clone ( ) ) ) ;
122
+ self . envs . push ( ( key. as_ref ( ) . to_os_string ( ) , val. as_ref ( ) . to_os_string ( ) ) ) ;
126
123
self . command . env ( key, val) ;
127
124
self
128
125
}
@@ -257,7 +254,7 @@ impl From<Command> for BootstrapCommand {
257
254
let program = command. get_program ( ) . to_owned ( ) ;
258
255
259
256
Self {
260
- program : program. clone ( ) . into_string ( ) . unwrap ( ) ,
257
+ program : program. clone ( ) ,
261
258
args : Vec :: new ( ) ,
262
259
envs : Vec :: new ( ) ,
263
260
cwd : None ,
0 commit comments