From 9db620a7a8c8634820136958a053d09dd602f02d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 26 Jul 2024 14:56:41 -0400 Subject: [PATCH] utils: Allow non-static str for spinner I have a use case for dynamic strings, this just requires duplicating the string for the progress bar. Signed-off-by: Colin Walters --- lib/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/utils.rs b/lib/src/utils.rs index 1b1d0cd9d..5ceae99dd 100644 --- a/lib/src/utils.rs +++ b/lib/src/utils.rs @@ -132,14 +132,14 @@ pub(crate) fn medium_visibility_warning(s: &str) { /// with an automatic spinner to show that we're not blocked. /// Note that generally the called function should not output /// anything to stdout as this will interfere with the spinner. -pub(crate) async fn async_task_with_spinner(msg: &'static str, f: F) -> T +pub(crate) async fn async_task_with_spinner(msg: &str, f: F) -> T where F: Future, { let pb = indicatif::ProgressBar::new_spinner(); let style = indicatif::ProgressStyle::default_bar(); pb.set_style(style.template("{spinner} {msg}").unwrap()); - pb.set_message(msg); + pb.set_message(msg.to_string()); pb.enable_steady_tick(Duration::from_millis(150)); // We need to handle the case where we aren't connected to // a tty, so indicatif would show nothing by default.