hoop 0.2.8

Fixed ring buffer that allows non-consuming iteration both ways
Documentation
  • Coverage
  • 84.62%
    11 out of 13 items documented1 out of 10 items with examples
  • Size
  • Source code size: 22.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.71 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • andoriyu/hoop
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • andoriyu

Hoop

Build Status codecov Crates.io

Very naive and probably non-perfomant implementation of fixed size circular buffer. The only difference between that one and the many others is: this one has double ended non-consuming iterator support.

Why?

Imagine you have some metrics data coming in and you need to aggregate over it and at msot you have to go 21 items deep. With Vec and VecDeque you will keep moving and/or allocationg things. This buffer allows you to simple keep writting to it and from time to time grab "Last N items" without removing it from buffer.

Installation

hoop is available on crates.io and can be included in your Cargo enabled project like this:

[dependencies]
hoop = "0.2.7"

Usage

let mut buffer = Hoop::with_capacity(4);
buffer.write('1');
buffer.write('2');
buffer.write('3');
buffer.write('4');
let mut iter = buffer.iter();
assert_eq!(Some(&'1'), iter.next());
assert_eq!(Some(&'4'), iter.next_back());
assert_eq!(Some(&'2'), iter.next());
assert_eq!(Some(&'3'), iter.next_back());
assert_eq!(None, iter.next());
assert_eq!(None, iter.next_back());