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:: { DefaultHasher , Hash , Hasher } ;
11
11
use std:: path:: Path ;
@@ -69,9 +69,9 @@ impl OutputMode {
69
69
/// [allow_failure]: BootstrapCommand::allow_failure
70
70
/// [delay_failure]: BootstrapCommand::delay_failure
71
71
pub struct BootstrapCommand {
72
- program : String ,
73
- args : Vec < String > ,
74
- envs : Vec < ( String , String ) > ,
72
+ program : OsString ,
73
+ args : Vec < OsString > ,
74
+ envs : Vec < ( OsString , OsString ) > ,
75
75
cwd : Option < PathBuf > ,
76
76
77
77
command : Command ,
@@ -90,8 +90,7 @@ impl<'a> BootstrapCommand {
90
90
}
91
91
92
92
pub fn arg < S : AsRef < OsStr > > ( & mut self , arg : S ) -> & mut Self {
93
- let arg_str = arg. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
94
- self . args . push ( arg_str. clone ( ) ) ;
93
+ self . args . push ( arg. as_ref ( ) . to_os_string ( ) ) ;
95
94
self . command . arg ( arg. as_ref ( ) ) ;
96
95
self
97
96
}
@@ -112,9 +111,7 @@ impl<'a> BootstrapCommand {
112
111
K : AsRef < OsStr > ,
113
112
V : AsRef < OsStr > ,
114
113
{
115
- let key_str = key. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
116
- let val_str = val. as_ref ( ) . to_string_lossy ( ) . into_owned ( ) ;
117
- self . envs . push ( ( key_str. clone ( ) , val_str. clone ( ) ) ) ;
114
+ self . envs . push ( ( key. as_ref ( ) . to_os_string ( ) , val. as_ref ( ) . to_os_string ( ) ) ) ;
118
115
self . command . env ( key, val) ;
119
116
self
120
117
}
@@ -249,7 +246,7 @@ impl From<Command> for BootstrapCommand {
249
246
let program = command. get_program ( ) . to_owned ( ) ;
250
247
251
248
Self {
252
- program : program. clone ( ) . into_string ( ) . unwrap ( ) ,
249
+ program : program. clone ( ) ,
253
250
args : Vec :: new ( ) ,
254
251
envs : Vec :: new ( ) ,
255
252
cwd : None ,
0 commit comments