Skip to content

Commit

Permalink
Add method for directly setting a value
Browse files Browse the repository at this point in the history
  • Loading branch information
Franklin Delehelle committed Nov 24, 2016
1 parent 654d53e commit 7f2b482
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,21 @@ impl<T: Write> ProgressBar<T> {
self.current
}

/// Manually set the current value of the bar
///
/// # Examples
/// ```no_run
/// use pbr::ProgressBar;
///
/// let mut pb = ProgressBar::new(10);
/// pb.set(8);
/// pb.finish();
pub fn set(&mut self, i: u64) -> u64 {
self.current = i;
self.tick();
self.current
}

/// Increment current value
pub fn inc(&mut self) -> u64 {
self.add(1)
Expand Down

0 comments on commit 7f2b482

Please sign in to comment.