sliding-ring 0.1.1

Cache-friendly sliding ring buffer keyed to an anchor coordinate for ultra-low-latency workloads.
Documentation
use sliding_ring::{Direction, SlidingRing};

#[derive(Clone, Copy, Default)]
struct Bucket {
    hits: u64,
}

fn main() {
    // Track hits per millisecond around the current time bucket.
    const DEPTH: u8 = 64;
    let mut ring = SlidingRing::<Bucket, DEPTH>::new(Bucket::default());
    for step in 0..DEPTH {
        ring.slot_mut(step).hits += 1;
    }

    let total: u64 = ring
        .iter_from_anchor(Direction::Forward)
        .map(|(_, bucket)| bucket.hits)
        .sum();
    println!("total hits: {}", total);
}