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

Mention the prefix and message placeholders in the with_ docs #529

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Changes from all 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
6 changes: 6 additions & 0 deletions src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ impl ProgressBar {
}

/// A convenience builder-like function for a progress bar with a given prefix
///
/// For the prefix to be visible, the `{prefix}` placeholder must be present in the template
/// (see [`ProgressStyle`]).
pub fn with_prefix(self, prefix: impl Into<Cow<'static, str>>) -> Self {
let mut state = self.state();
state.state.prefix = TabExpandedString::new(prefix.into(), state.tab_width);
Expand All @@ -88,6 +91,9 @@ impl ProgressBar {
}

/// A convenience builder-like function for a progress bar with a given message
///
/// For the message to be visible, the `{msg}` placeholder must be present in the template (see
/// [`ProgressStyle`]).
pub fn with_message(self, message: impl Into<Cow<'static, str>>) -> Self {
let mut state = self.state();
state.state.message = TabExpandedString::new(message.into(), state.tab_width);
Expand Down