5 releases
0.2.0 | Apr 6, 2024 |
---|---|
0.1.4 | Oct 2, 2023 |
0.1.3 | Oct 2, 2023 |
0.1.2 | Oct 2, 2023 |
0.1.1 | Oct 2, 2023 |
#843 in Command-line interface
57 downloads per month
14KB
212 lines
simple-tqdm
A small rust library that wraps around indicatif
, and
tries to be similar to python's tqdm
library.
lib.rs
:
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);
Dependencies
~2.4–9.5MB
~84K SLoC