From 6fb943d0f6e284c1e8fd8cfa13b656ae3646579c Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 7 Mar 2022 19:33:27 +0000 Subject: [PATCH] Refactor use of `export_path` as suggested. Co-authored-by: Sean Bowe Signed-off-by: Daira Hopwood --- src/rust/bin/wallet_tool.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rust/bin/wallet_tool.rs b/src/rust/bin/wallet_tool.rs index e42bdd3df..db94e8787 100644 --- a/src/rust/bin/wallet_tool.rs +++ b/src/rust/bin/wallet_tool.rs @@ -336,14 +336,16 @@ fn run(opts: &CliOptions) -> anyhow::Result<()> { // This panic hook allows us to make a best effort to clear the screen (and then print // another reminder about secrets in the export file) even if a panic occurs. - let moved_export_path = export_path.to_string(); // borrow checker workaround let old_hook = panic::take_hook(); - panic::set_hook(Box::new(move |panic_info| { - clear_and_show_cautions(&moved_export_path); + { + let export_path = export_path.to_string(); + panic::set_hook(Box::new(move |panic_info| { + clear_and_show_cautions(&export_path); - let s = panic_info.payload().downcast_ref::<&str>().unwrap_or(&""); - eprintln!("\nPanic: {}\n{:?}", s, Backtrace::new()); - })); + let s = panic_info.payload().downcast_ref::<&str>().unwrap_or(&""); + eprintln!("\nPanic: {}\n{:?}", s, Backtrace::new()); + })); + } let res = (|| -> anyhow::Result<()> { println!("The recovery phrase is:\n");