Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add builder-like with_finish method to ProgressBarIter. #548

Merged
merged 3 commits into from
Jun 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tokio::io::{ReadBuf, SeekFrom};

use crate::progress_bar::ProgressBar;
use crate::style::ProgressStyle;
use crate::state::ProgressFinish;

/// Wraps an iterator to display its progress.
pub trait ProgressIterator
Expand Down Expand Up @@ -103,6 +104,14 @@ impl<T> ProgressBarIter<T> {
self.progress = self.progress.with_elapsed(elapsed);
self
}

/// Builder-like function for setting underlying progress bar's finish behavior.
///
/// See [ProgressBar::with_finish].
pub fn with_finish(mut self, finish: ProgressFinish) -> Self {
self.progress = self.progress.with_finish(finish);
self
}
}

impl<S, T: Iterator<Item = S>> Iterator for ProgressBarIter<T> {
Expand Down