From 91255463a2b846a39a452c2b2119d3cafeda848c Mon Sep 17 00:00:00 2001 From: "Yubing Dong (Tom)" Date: Thu, 4 Jul 2019 02:00:57 -0700 Subject: [PATCH] Support increasing the length of the progress bar with a delta. This is useful when new work arrives when tracking the progress of existing work. --- src/progress.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/progress.rs b/src/progress.rs index 67c4a937..c06f0e13 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -523,6 +523,13 @@ impl ProgressBar { }) } + /// Increase the length of the progress bar. + pub fn inc_length(&self, delta: u64) { + self.update_and_draw(|state| { + state.len = state.len.saturating_add(delta); + }) + } + /// Sets the current prefix of the progress bar. pub fn set_prefix(&self, prefix: &str) { let prefix = prefix.to_string();