File tree Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Original file line number Diff line number Diff line change @@ -256,34 +256,30 @@ impl ProcessBuilder {
256
256
None => return ,
257
257
}
258
258
} ;
259
- {
260
- // scope for new_lines
261
- let new_lines = if capture_output {
262
- let dst = if is_out { & mut stdout } else { & mut stderr } ;
263
- let start = dst. len ( ) ;
264
- let data = data. drain ( ..idx) ;
265
- dst. extend ( data) ;
266
- & dst[ start..]
259
+
260
+ let new_lines = & data[ ..idx] ;
261
+
262
+ for line in String :: from_utf8_lossy ( new_lines) . lines ( ) {
263
+ if callback_error. is_some ( ) {
264
+ break ;
265
+ }
266
+ let callback_result = if is_out {
267
+ on_stdout_line ( line)
267
268
} else {
268
- & data [ ..idx ]
269
+ on_stderr_line ( line )
269
270
} ;
270
- for line in String :: from_utf8_lossy ( new_lines) . lines ( ) {
271
- if callback_error. is_some ( ) {
272
- break ;
273
- }
274
- let callback_result = if is_out {
275
- on_stdout_line ( line)
276
- } else {
277
- on_stderr_line ( line)
278
- } ;
279
- if let Err ( e) = callback_result {
280
- callback_error = Some ( e) ;
281
- }
271
+ if let Err ( e) = callback_result {
272
+ callback_error = Some ( e) ;
273
+ break ;
282
274
}
283
275
}
284
- if !capture_output {
285
- data. drain ( ..idx) ;
276
+
277
+ if capture_output {
278
+ let dst = if is_out { & mut stdout } else { & mut stderr } ;
279
+ dst. extend ( new_lines) ;
286
280
}
281
+
282
+ data. drain ( ..idx) ;
287
283
} ) ?;
288
284
child. wait ( )
289
285
} ) ( )
You can’t perform that action at this time.
0 commit comments