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

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

#326 in Caching

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

~94KB