Skip to main content

track

Function track 

Source
pub fn track<T: IntoIterator>(
    sequence: T,
    _description: &str,
    total: Option<f64>,
) -> TrackIterator<T::IntoIter> 
Expand description

Create a TrackIterator from a sequence (standalone, item counting only).

This standalone function does NOT update any Progress display — it only counts consumed items via TrackIterator::count. To get live progress updates, use Progress::track instead and call Progress::update with the tracker’s progress_id and count() in your loop body.

§Example (count only)

use rusty_rich::progress::track;

let tracker = track(0..100, "Processing", None);
for item in tracker {
    // item is yielded; tracker.count() tracks position
}

§Example (with Progress display)

use rusty_rich::Progress;

let mut progress = Progress::new();
let items: Vec<i32> = (0..100).collect();
let tracker = progress.track(items, "Processing", None);
let task_id = tracker.progress_id;
let mut count = 0;
for item in tracker {
    count += 1;
    progress.update(task_id, count as f64);
    // process item
}