Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/anstyle-progress/src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct TermProgress {

impl TermProgress {
/// No progress to display
pub fn none() -> Self {
pub const fn none() -> Self {
Self {
status: None,
percent: None,
Expand All @@ -37,31 +37,31 @@ impl TermProgress {
/// Start a progress indicator
///
/// This starts in an indeterminate state
pub fn start() -> Self {
pub const fn start() -> Self {
Self::none().status(TermProgressStatus::Normal)
}

/// Start an error indicator
pub fn error() -> Self {
pub const fn error() -> Self {
Self::none().status(TermProgressStatus::Error)
}

/// Remove the indicator
pub fn remove() -> Self {
pub const fn remove() -> Self {
Self::none().status(TermProgressStatus::Removed)
}

/// Set progress percentage (between `0..=100`)
///
/// Without setting this, progress will be indeterminate
pub fn percent(mut self, percent: u8) -> Self {
pub const fn percent(mut self, percent: u8) -> Self {
assert!(matches!(percent, 0..=100));
self.percent = Some(percent);
self
}

/// Change the reported status
pub fn status(mut self, status: TermProgressStatus) -> Self {
pub const fn status(mut self, status: TermProgressStatus) -> Self {
self.status = Some(status);
self
}
Expand Down
Loading