Skip to content

Commit b31a0be

Browse files
sunshowersdjc
authored andcommitted
Add ProgressBar::set_elapsed
Similar to the other `set_` methods -- it's possible to do this as `bar.clone().with_elapsed` but not very intuitive what that means.
1 parent 368de49 commit b31a0be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/progress_bar.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ impl ProgressBar {
328328
state.update_estimate_and_draw(Instant::now());
329329
}
330330

331+
/// Sets the elapsed time for the progress bar
332+
pub fn set_elapsed(&self, elapsed: Duration) {
333+
self.state().state.started = Instant::now().checked_sub(elapsed).unwrap();
334+
}
335+
331336
/// Creates a new weak reference to this [`ProgressBar`]
332337
pub fn downgrade(&self) -> WeakProgressBar {
333338
WeakProgressBar {

0 commit comments

Comments
 (0)