pub trait AvanceIteratorwhere
    Self: Sized + Iterator,{
    // Provided method
    fn avance(self) -> AvanceIter<Self>  { ... }
}
Expand description

Wrap an iterator to display its progress

Provided Methods§

source

fn avance(self) -> AvanceIter<Self>

Wrap an iterator to display its progress, using the upper hound of iterator’s size as the total length of the progress bar.

See another way of progressing with an iterator at AvanceBar::with_iter

Examples
for _ in (0..1000).avance() {
    // ...
}
Examples found in repository?
examples/single.rs (line 8)
6
7
8
9
10
fn main() {
    (0..1000)
        .avance()
        .for_each(|_| thread::sleep(Duration::from_millis(5)));
}
More examples
Hide additional examples
examples/train.rs (line 12)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() {
    // Suppose we're training a model and here's 200 epoches
    let epoch = 200;
    let mut accuracy = 30.0;

    (0..epoch)
        .avance()
        .with_style(Style::Block)
        .with_pb()
        .for_each(|(_, pb)| {
            thread::sleep(Duration::from_millis(20));

            accuracy += 0.34;

            // Display the accuracy through the postfix
            pb.set_postfix(format!("acc={:.2}", accuracy));
        });
}

Implementors§

source§

impl<Iter: Iterator> AvanceIterator for Iter