1

How to make the following code work?

let mut process_guard: MutexGuard<Option<std::process::Child>> = process.lock().unwrap();
if let Some(child) = *process_guard {
    child.kill();
    *process_guard = None;
}

Solution:

if let Some(mut child) = (*process_guard).take() {
    child.kill();
}
vasily
  • 2,850
  • 1
  • 24
  • 40

0 Answers0