pub trait ProgressIteratorExt: Iterator + Sized {
// Provided methods
fn inkling(self) -> InklingIter<Self> ⓘ { ... }
fn inkling_with(self, loader: Loader) -> InklingIter<Self> ⓘ { ... }
}Expand description
Extension trait that wraps any iterator in a progress reveal.
Provided Methods§
Sourcefn inkling(self) -> InklingIter<Self> ⓘ
fn inkling(self) -> InklingIter<Self> ⓘ
Reveal a loader while iterating, inferring the total from size_hint.
Examples found in repository?
examples/loader.rs (line 24)
21fn main() {
22 match std::env::args().nth(1).as_deref() {
23 Some("iter") => {
24 for _ in (0..100).inkling() {
25 work(20);
26 }
27 }
28 Some("spinner") => {
29 let loader = Loader::spinner();
30 loader.set_message("Doing something mysterious");
31 work(2500);
32 loader.finish();
33 }
34 Some("threads") => {
35 let loader = Loader::new(120);
36 loader.set_message("Four workers, one dragon");
37 thread::scope(|s| {
38 for _ in 0..4 {
39 let handle = loader.handle();
40 s.spawn(move || {
41 for _ in 0..30 {
42 work(30);
43 handle.inc(1);
44 }
45 });
46 }
47 });
48 loader.finish();
49 }
50 Some("rainbow") => {
51 let loader = Loader::builder()
52 .total(100)
53 .style(inkling::render::Style::rainbow())
54 .message("Tasting the rainbow")
55 .start();
56 for _ in 0..100 {
57 work(20);
58 loader.inc(1);
59 }
60 loader.finish();
61 }
62 _ => {
63 let total: u64 = 100;
64 let loader = Loader::new(total);
65 loader.set_message("Summoning the dragon");
66 for _ in 0..total {
67 work(20);
68 loader.inc(1);
69 }
70 loader.finish();
71 }
72 }
73}Sourcefn inkling_with(self, loader: Loader) -> InklingIter<Self> ⓘ
fn inkling_with(self, loader: Loader) -> InklingIter<Self> ⓘ
Reveal a specific, pre-configured loader while iterating.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".