@@ -3,7 +3,7 @@ use crate::{process, CmdResult, FunResult};
3
3
use os_pipe:: PipeReader ;
4
4
use std:: any:: Any ;
5
5
use std:: fmt:: Display ;
6
- use std:: io:: { BufRead , BufReader , Error , ErrorKind , Read , Result } ;
6
+ use std:: io:: { BufRead , BufReader , Error , Read , Result } ;
7
7
use std:: process:: { Child , ExitStatus } ;
8
8
use std:: thread:: JoinHandle ;
9
9
@@ -37,9 +37,11 @@ impl CmdChildren {
37
37
let last_child_res = last_child. wait ( true ) ;
38
38
let other_children_res = Self :: wait_children ( & mut self . children ) ;
39
39
40
- self . ignore_error
41
- . then_some ( Ok ( ( ) ) )
42
- . unwrap_or ( last_child_res. and ( other_children_res) )
40
+ if self . ignore_error {
41
+ Ok ( ( ) )
42
+ } else {
43
+ last_child_res. and ( other_children_res)
44
+ }
43
45
}
44
46
45
47
fn wait_children ( children : & mut Vec < CmdChild > ) -> CmdResult {
@@ -166,9 +168,11 @@ impl FunChildren {
166
168
let other_children_res = CmdChildren :: wait_children ( & mut self . children ) ;
167
169
let _ = stderr_thread. join ( ) ;
168
170
169
- self . ignore_error
170
- . then_some ( Ok ( ( ) ) )
171
- . unwrap_or ( last_child_res. and ( other_children_res) )
171
+ if self . ignore_error {
172
+ Ok ( ( ) )
173
+ } else {
174
+ last_child_res. and ( other_children_res)
175
+ }
172
176
}
173
177
174
178
/// Returns the OS-assigned process identifiers associated with these children processes.
@@ -183,10 +187,11 @@ impl FunChildren {
183
187
let last_child = self . children . pop ( ) . unwrap ( ) ;
184
188
let last_child_res = last_child. wait_with_all ( capture_stderr, & mut stdout, & mut stderr) ;
185
189
let other_children_res = CmdChildren :: wait_children ( & mut self . children ) ;
186
- let cmd_result = self
187
- . ignore_error
188
- . then_some ( Ok ( ( ) ) )
189
- . unwrap_or ( last_child_res. and ( other_children_res) ) ;
190
+ let cmd_result = if self . ignore_error {
191
+ Ok ( ( ) )
192
+ } else {
193
+ last_child_res. and ( other_children_res)
194
+ } ;
190
195
191
196
let mut stdout: String = String :: from_utf8_lossy ( & stdout) . into ( ) ;
192
197
if stdout. ends_with ( '\n' ) {
@@ -345,10 +350,9 @@ trait ChildOutcome: Display {
345
350
if self . success ( ) {
346
351
Ok ( ( ) )
347
352
} else {
348
- Err ( Error :: new (
349
- ErrorKind :: Other ,
350
- format ! ( "Running [{cmd}] exited with error; {self} at {file}:{line}" ) ,
351
- ) )
353
+ Err ( Error :: other ( format ! (
354
+ "Running [{cmd}] exited with error; {self} at {file}:{line}"
355
+ ) ) )
352
356
}
353
357
}
354
358
}
@@ -392,10 +396,9 @@ impl CmdChildHandle {
392
396
format ! ( "Killing process [{cmd}] failed with error: {e} at {file}:{line}" ) ,
393
397
)
394
398
} ) ,
395
- CmdChildHandle :: Thread ( _thread) => Err ( Error :: new (
396
- ErrorKind :: Other ,
397
- format ! ( "Killing thread [{cmd}] failed: not supported at {file}:{line}" ) ,
398
- ) ) ,
399
+ CmdChildHandle :: Thread ( _thread) => Err ( Error :: other ( format ! (
400
+ "Killing thread [{cmd}] failed: not supported at {file}:{line}"
401
+ ) ) ) ,
399
402
CmdChildHandle :: SyncFn => Ok ( ( ) ) ,
400
403
}
401
404
}
0 commit comments