Crate iter_progress [] [src]

Wrap an iterator, and get progress data as it's executed. A more advanced .enumerate()

Usage

Call .progress() on any Iterator, and get a new iterator that yields (ProgressRecord, T), where T is the original value. A ProgressRecord has many helpful methods to query the current state of the iterator

Example

use iter_progress::ProgressableIter;
// Create an iterator that goes from 0 to 1,000
let my_iter = 0..1_000;
let mut progressor = my_iter.progress();

// This new iterator returns a struct with the current state, and the inner object returned by
// the iterator
let (state, number) = progressor.next().unwrap();
assert_eq!(number, 0);
 
// We can now use methods on `state` to find out about this object

// 0 to 1
assert_eq!(state.fraction(), Some(0.001));
// We are 0.1% the way through
assert_eq!(state.percent(), Some(0.1));

There are numerous ergnomic methods for access data on the state of the iterator

Structs

ProgressRecord

Every step of the underlying iterator, one of these is generated. It contains all the information of how this iterator is progresing. Use the methods to access data on it.

ProgressRecorderIter

Wraps an iterator and keeps track of state used for ProgressRecord's

Traits

ProgressableIter

An iterator that records it's progress as it goes along