Debian Codegraph @

debian/rust-vendor/indicatif/examples/morebars.rs

raw
1 use std::sync::Arc;
2 use std::thread;
3 use std::time::Duration;
4
5 use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
6
7 fn main() {
8 let m = Arc::new(MultiProgress::new());
9 let sty = ProgressStyle::with_template("{bar:40.green/yellow} {pos:>7}/{len:7}").unwrap();
10
11 let pb = m.add(ProgressBar::new(5));
12 pb.set_style(sty.clone());
13
14 // make sure we show up at all. otherwise no rendering
15 // event.
16 pb.tick();
17 for _ in 0..5 {
18 let pb2 = m.add(ProgressBar::new(128));
19 pb2.set_style(sty.clone());
20 for _ in 0..128 {
21 thread::sleep(Duration::from_millis(5));
22 pb2.inc(1);
23 }
24 pb2.finish();
25 pb.inc(1);
26 }
27 pb.finish_with_message("done");
28 }