Skip to content

feat: allow constructing and setting the progress bar len to None#664

Merged
djc merged 2 commits intoconsole-rs:mainfrom
cdellacqua:main
Nov 12, 2024
Merged

feat: allow constructing and setting the progress bar len to None#664
djc merged 2 commits intoconsole-rs:mainfrom
cdellacqua:main

Conversation

@cdellacqua
Copy link
Copy Markdown
Contributor

For situations where the length of a progress bar can only be discovered after some processing, it might be more appropriate to show an empty bar rather than a full one of length 0 (0/0 is represented with a ratio of 1.0).

This PR introduces a new constructor, ProgressBar::empty(), and a new method, ProgressBar::unset_length(). These two allow library users to have a length of None, which is represented as a ratio of 0.0, achieving the empty state.

Copy link
Copy Markdown
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, thanks.

@djc djc merged commit e84863a into console-rs:main Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants