Crate simple_tqdm

Source
Expand description

simple-tqdm is a small wrapper around indicatif that tries to be similar to python’s tqdm library.

tqdm comes with both a tqdm function and a Tqdm trait depending on your preference.

§Example

use simple_tqdm::tqdm;

for _ in tqdm(0..2 << 24) {}
Or if you'd like to customize the progress bar:
use simple_tqdm::{Tqdm, Config};

let config = Config::new().with_unit("num");
for _ in (0..2 << 24).tqdm_config(config) {}

Or if you’d like multiple bars.

use simple_tqdm::{Tqdm, Config};
fn main() {
    let config = Config::new().with_progress_chars(">= ");
    std::thread::scope(|scope| {
        for _ in 0..3 {
            scope.spawn(|| for _ in (0..2 << 24).tqdm_config(config.clone()) {});
        }   
    });
}

§Parallel Iterators

tqdm also has optional support for parallel iterators with Rayon. In your Cargo.toml, use the “rayon” feature:

[dependencies]
simple-tqdm = {version = "*", features = ["rayon"]}

And then use it like this:

use simple_tqdm::ParTqdm;
use rayon::prelude::*;

let vec: Vec<_> = (0..100000).into_par_iter().tqdm().map(|i| i + 1).collect();
assert_eq!(vec[0], 1);

Structs§

Config
Configuration for the Tqdm and ParTqdm progress bars.

Traits§

ParTqdm
Wraps a Rayon parallel iterator.
Tqdm
Wraps an iterator to display it’s progress.

Functions§

par_tqdm
Equivalent to using the ParTqdm trait method.
tqdm
Equivalent to using the Tqdm trait method.