@@ -43,12 +43,7 @@ extern crate winapi;
43
43
#[ cfg( not( windows) ) ]
44
44
use std:: process:: { Command , Stdio } ;
45
45
46
- use std:: {
47
- ffi:: OsStr ,
48
- io,
49
- process:: ExitStatus ,
50
- thread
51
- } ;
46
+ use std:: { ffi:: OsStr , io, process:: ExitStatus , thread} ;
52
47
53
48
#[ cfg( not( any( target_os = "windows" , target_os = "macos" ) ) ) ]
54
49
pub fn that < T : AsRef < OsStr > + Sized > ( path : T ) -> io:: Result < ExitStatus > {
@@ -111,15 +106,12 @@ pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> io::Result<ExitStatus> {
111
106
}
112
107
113
108
#[ cfg( not( any( target_os = "windows" , target_os = "macos" ) ) ) ]
114
- pub fn with < T : AsRef < OsStr > +Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
115
- Command :: new ( app. into ( ) )
116
- . arg ( path. as_ref ( ) )
117
- . spawn ( ) ?
118
- . wait ( )
109
+ pub fn with < T : AsRef < OsStr > + Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
110
+ Command :: new ( app. into ( ) ) . arg ( path. as_ref ( ) ) . spawn ( ) ?. wait ( )
119
111
}
120
112
121
113
#[ cfg( target_os = "windows" ) ]
122
- pub fn with < T : AsRef < OsStr > + Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
114
+ pub fn with < T : AsRef < OsStr > + Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
123
115
use std:: os:: windows:: ffi:: OsStrExt ;
124
116
use std:: os:: windows:: process:: ExitStatusExt ;
125
117
use std:: ptr;
@@ -130,7 +122,9 @@ pub fn with<T:AsRef<OsStr>+Sized>(path: T, app: impl Into<String>) -> io::Result
130
122
131
123
let path = windows:: convert_path ( path. as_ref ( ) ) ?;
132
124
let operation: Vec < u16 > = OsStr :: new ( "open\0 " ) . encode_wide ( ) . collect ( ) ;
133
- let app_name: Vec < u16 > = OsStr :: new ( & format ! ( "{}\0 " , app. into( ) ) ) . encode_wide ( ) . collect ( ) ;
125
+ let app_name: Vec < u16 > = OsStr :: new ( & format ! ( "{}\0 " , app. into( ) ) )
126
+ . encode_wide ( )
127
+ . collect ( ) ;
134
128
let result = unsafe {
135
129
ShellExecuteW (
136
130
ptr:: null_mut ( ) ,
@@ -149,7 +143,7 @@ pub fn with<T:AsRef<OsStr>+Sized>(path: T, app: impl Into<String>) -> io::Result
149
143
}
150
144
151
145
#[ cfg( target_os = "macos" ) ]
152
- pub fn with < T : AsRef < OsStr > + Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
146
+ pub fn with < T : AsRef < OsStr > + Sized > ( path : T , app : impl Into < String > ) -> io:: Result < ExitStatus > {
153
147
Command :: new ( "open" )
154
148
. arg ( path. as_ref ( ) )
155
149
. arg ( "-a" )
@@ -169,7 +163,7 @@ pub fn that_in_background<T: AsRef<OsStr> + Sized>(
169
163
170
164
pub fn with_in_background < T : AsRef < OsStr > + Sized > (
171
165
path : T ,
172
- app : impl Into < String >
166
+ app : impl Into < String > ,
173
167
) -> thread:: JoinHandle < io:: Result < ExitStatus > > {
174
168
let path = path. as_ref ( ) . to_os_string ( ) ;
175
169
let app = app. into ( ) ;
0 commit comments