#iterator #cache #data-structures #adaptor #produce #values #copy

reiterate

Iterator adaptor with caching that allows reiterating over the same iterator through the cache

4 releases

0.1.3 May 20, 2019
0.1.2 Mar 29, 2019
0.1.1 Mar 29, 2019
0.1.0 Feb 2, 2019

#284 in Caching

Download history 3/week @ 2024-01-29 7/week @ 2024-02-19 22/week @ 2024-02-26 4/week @ 2024-03-04 22/week @ 2024-03-11 5/week @ 2024-03-25 35/week @ 2024-04-01

63 downloads per month

MIT/Apache

8KB
155 lines

reiterate

Build Status License: MIT/Apache-2.0

An adaptor around an iterator that can produce multiple iterators sharing an underlying cache.

The underlying iterator must produce heap-allocated StableDeref values, e.g. Box or String. If you have an iterator that produces Copy values, use CopyReiterator instead.

use reiterate::Reiterate;
let x = vec!["a".to_string(), "b".to_string(), "c".to_string(), "d".to_string()];
let reiterate = Reiterate::new(x);
for i in &reiterate {
    println!("{}", i);    
}
for i in &reiterate {
    // will reuse cached values
    println!("{}", i);    
}

Dependencies

~96KB