8000 per_sec does not respect width specifier · Issue #663 · console-rs/indicatif · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
per_sec does not respect width specifier #663
Open
@rlee287

Description

@rlee287

Reproducer (using indicatif 0.17.8, default feature set):

use indicatif::{ProgressBar, ProgressStyle};

fn main() {
    let pb_style = ProgressStyle::default_bar()
        .template("{bar:16} | {pos:>6}/{len:6} | {per_sec:>8}")
        .unwrap();

    let pb = ProgressBar::new(100000).with_style(pb_style);

    for _ in 0..1000 {
        std::thread::sleep(std::time::Duration::from_secs_f64(0.01));
        pb.inc(100);
    }
    pb.finish();
}

The progress bar that's left after the program runs:

████████████████ | 100000/100000 | 9,631.6687/s

Despite per_sec specifying a width of 8 characters, the final per_sec display is 12 characters wide. I would have expected the formatter to trim the number of digits after the decimal point to reduce the width instead.

Compressed asciinema recording of the above program running on my machine:

pb_per_sec.cast.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0