Skip to content

Commit

Permalink
utils: Allow non-static str for spinner
Browse files Browse the repository at this point in the history
I have a use case for dynamic strings, this just requires
duplicating the string for the progress bar.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Jul 26, 2024
1 parent cf6c028 commit 9db620a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F, T>(msg: &'static str, f: F) -> T
pub(crate) async fn async_task_with_spinner<F, T>(msg: &str, f: F) -> T
where
F: Future<Output = T>,
{
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.
Expand Down

0 comments on commit 9db620a

Please sign in to comment.