example/
example.rs

1use std::{thread, time::Duration};
2
3fn main() {
4	// Default
5	for _ in progression::bar(0..1_000) {
6		thread::sleep(Duration::from_millis(1));
7	}
8
9	// Cargo style
10	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
11		thread::sleep(Duration::from_millis(1));
12	}
13
14	// Unicode style
15	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
16		thread::sleep(Duration::from_millis(1));
17	}
18
19	// Uses `slice.chunks` internally for lower overhead on large numbers of items
20	for _ in progression::bar_chunks(10, &[0; 1_000]) {
21		thread::sleep(Duration::from_millis(1));
22	}
23
24	// Custom
25	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('ยท'), ..Default::default() }) {
26		thread::sleep(Duration::from_millis(1));
27	}
28
29	// Manual
30	let items = vec![1, 2, 3, 4, 5];
31	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });
32
33	for _ in items {
34		thread::sleep(Duration::from_millis(100));
35		bar.inc(1);
36	}
37
38	bar.finish();
39}