diff --git a/plotly/src/plot.rs b/plotly/src/plot.rs index 38833382..bcfa7f45 100644 --- a/plotly/src/plot.rs +++ b/plotly/src/plot.rs @@ -262,10 +262,13 @@ impl Plot { // Save the rendered plot to the temp file. let temp_path = temp.to_str().unwrap(); - let mut file = File::create(temp_path).unwrap(); - file.write_all(rendered.as_bytes()) - .expect("failed to write html output"); - file.flush().unwrap(); + + { + let mut file = File::create(temp_path).unwrap(); + file.write_all(rendered.as_bytes()) + .expect("failed to write html output"); + file.flush().unwrap(); + } // Hand off the job of opening the browser to an OS-specific implementation. Plot::show_with_default_app(temp_path); @@ -288,10 +291,13 @@ impl Plot { // Save the rendered plot to the temp file. let temp_path = temp.to_str().unwrap(); - let mut file = File::create(temp_path).unwrap(); - file.write_all(rendered.as_bytes()) - .expect("failed to write html output"); - file.flush().unwrap(); + + { + let mut file = File::create(temp_path).unwrap(); + file.write_all(rendered.as_bytes()) + .expect("failed to write html output"); + file.flush().unwrap(); + } // Hand off the job of opening the browser to an OS-specific implementation. Plot::show_with_default_app(temp_path); @@ -467,7 +473,7 @@ impl Plot { Command::new("cmd") .arg("/C") .arg(format!("start {}", temp_path)) - .spawn() + .output() .expect(DEFAULT_HTML_APP_NOT_FOUND); } }