ring_pair 0.2.1

Tiny fixed-size ring buffer specialized for exactly two elements
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 1 items with examples
  • Size
  • Source code size: 28.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.96 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kauzarc/ring_pair
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kauzarc

ring_pair

Tiny ring-buffer types specialized for exactly two elements.

Types

  • RingPair<T>: inline storage with [T; 2]
  • BoxedRingPair<T>: heap storage with Box<[T; 2]>

Both provide O(1) push, push_with, and accessors for older/newer entries.

Example

use ring_pair::{BoxedRingPair, RingPair};

let mut inline = RingPair::new(1);
inline.push(2);
assert_eq!(inline.as_pair(), (&1, &2));

let mut boxed = BoxedRingPair::new(String::from("a"));
boxed.push(String::from("b"));
assert_eq!(boxed.as_pair(), (&String::from("a"), &String::from("b")));

Development

cargo test