Skip to content

Commit

Permalink
Allow creating an empty WeakProgressBar
Browse files Browse the repository at this point in the history
  • Loading branch information
ishitatsuyuki authored and djc committed Dec 20, 2021
1 parent 67a8f9f commit ffb3927
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/progress_bar.rs
Expand Up @@ -766,12 +766,19 @@ impl MultiProgress {
/// A weak reference to a `ProgressBar`.
///
/// Useful for creating custom steady tick implementations
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct WeakProgressBar {
state: Weak<Mutex<ProgressState>>,
}

impl WeakProgressBar {
/// Create a new `WeakProgressBar` that returns `None` when [`upgrade`] is called.
///
/// [`upgrade`]: WeakProgressBar::upgrade
pub fn new(&self) -> WeakProgressBar {
Default::default()
}

/// Attempts to upgrade the Weak pointer to a [`ProgressBar`], delaying dropping of the inner
/// value if successful. Returns `None` if the inner value has since been dropped.
///
Expand Down

0 comments on commit ffb3927

Please sign in to comment.