pub struct Config<'a> {
pub width: Option<u64>,
pub default_width: u64,
pub delimiters: (char, char),
pub style: Style,
pub space_char: char,
pub prefix: &'a str,
pub unit: &'a str,
pub num_width: usize,
pub throttle_millis: u64,
}
Fields§
§width: Option<u64>
§default_width: u64
§delimiters: (char, char)
§style: Style
§space_char: char
§prefix: &'a str
§unit: &'a str
§num_width: usize
§throttle_millis: u64
Implementations§
Source§impl Config<'_>
impl Config<'_>
pub fn ascii() -> Self
Sourcepub fn unicode() -> Self
pub fn unicode() -> Self
Examples found in repository?
examples/example.rs (line 15)
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}
Sourcepub fn cargo() -> Self
pub fn cargo() -> Self
Examples found in repository?
examples/example.rs (line 10)
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}
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Config<'a>
impl<'a> RefUnwindSafe for Config<'a>
impl<'a> Send for Config<'a>
impl<'a> Sync for Config<'a>
impl<'a> Unpin for Config<'a>
impl<'a> UnwindSafe for Config<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more