Skip to main content

ProgressIteratorExt

Trait ProgressIteratorExt 

Source
pub trait ProgressIteratorExt: Iterator + Sized {
    // Required methods
    fn progress(self, description: &str) -> ProgressIter<Self> ;
    fn progress_with_total(
        self,
        description: &str,
        total: f64,
    ) -> ProgressIter<Self> ;
}
Expand description

Extension trait that adds .progress() to any iterator, wrapping it with a live progress bar.

The progress bar total is inferred from size_hint() when an upper bound is available (e.g. Vec::iter(), Range). For iterators without a known length the bar runs in indeterminate mode.

§Examples

use gilt::progress::ProgressIteratorExt;

// Range -- total inferred from size_hint
for i in (0..100).progress("Counting") {
    // work
}

// Vec -- total inferred from size_hint
let items = vec![1, 2, 3, 4, 5];
for item in items.iter().progress("Loading") {
    // work
}

Required Methods§

Source

fn progress(self, description: &str) -> ProgressIter<Self>

Wrap this iterator with a progress bar.

The progress bar total is inferred from size_hint() if an upper bound is available; otherwise the bar is indeterminate.

Source

fn progress_with_total( self, description: &str, total: f64, ) -> ProgressIter<Self>

Wrap this iterator with a progress bar, explicitly setting the total.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§